java.lang.Object
hudson.model.AbstractDescribableImpl<Metric>
io.jenkins.plugins.interactiveinput.output.Metric
All Implemented Interfaces:
Describable<Metric>, Serializable

public class Metric extends AbstractDescribableImpl<Metric> implements Serializable
A single statistic published by the interactiveOutput step: a labelled value with an optional unit and an optional stable key.

Rendered as a KPI card / table row on the build page. When the value parses as a number and a key is set, the value also feeds the per-job trend chart (the key identifies the series across builds). Instances are immutable, XStream-persistable (they are stored inside the build's InteractiveOutputBuildAction) and a Describable so the step's config.jelly can render them as a repeatable nested form block.

See Also:
  • Constructor Details

    • Metric

      @DataBoundConstructor public Metric(@NonNull String label, @NonNull String value)
      Parameters:
      label - human-readable label (required)
      value - the value as text (required); may be numeric (feeds the trend) or free-form
  • Method Details

    • setUnit

      @DataBoundSetter public void setUnit(@CheckForNull String unit)
    • setKey

      @DataBoundSetter public void setKey(@CheckForNull String key)
    • getLabel

      @NonNull public String getLabel()
    • getValue

      @NonNull public String getValue()
    • getUnit

      @CheckForNull public String getUnit()
    • getKey

      @CheckForNull public String getKey()
    • seriesKey

      @NonNull public String seriesKey()
      Returns:
      the stable series id for the trend: key if set, otherwise the label.
    • numericValue

      public double numericValue()
      Returns:
      the value parsed as a double for the trend chart, or Double.NaN if it is not a plain number. Strips a leading currency symbol and grouping commas so "$1,234.5" parses.
    • isNumeric

      public boolean isNumeric()
      Returns:
      true if the value is numeric (and therefore usable in the trend chart).
    • getDisplayValue

      @NonNull public String getDisplayValue()
      Returns:
      the value with its unit appended (for display), e.g. "12.4 kg".
    • toJson

      @NonNull public net.sf.json.JSONObject toJson()