Class CoverageBuildAction

java.lang.Object
io.jenkins.plugins.util.BuildAction<edu.hm.hafner.coverage.Node>
io.jenkins.plugins.coverage.metrics.steps.CoverageBuildAction
All Implemented Interfaces:
Action, ModelObject, Serializable, RunAction2, SimpleBuildStep.LastBuildAction, org.kohsuke.stapler.StaplerProxy

public final class CoverageBuildAction extends io.jenkins.plugins.util.BuildAction<edu.hm.hafner.coverage.Node> implements org.kohsuke.stapler.StaplerProxy
Controls the life cycle of the coverage results in a job. This action persists the results of a build and displays a summary on the build page. The actual visualization of the results is defined in the matching summary.jelly file. This action also provides access to the coverage details: these are rendered using a new view instance.
Author:
Ullrich Hafner
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    CoverageBuildAction(Run<?,?> owner, String id, String optionalName, String icon, edu.hm.hafner.coverage.Node result, io.jenkins.plugins.util.QualityGateResult qualityGateResult, edu.hm.hafner.util.FilteredLog log)
    Creates a new instance of CoverageBuildAction.
    CoverageBuildAction(Run<?,?> owner, String id, String optionalName, String icon, edu.hm.hafner.coverage.Node result, io.jenkins.plugins.util.QualityGateResult qualityGateResult, edu.hm.hafner.util.FilteredLog log, String referenceBuildId, List<? extends edu.hm.hafner.coverage.Difference> delta, List<? extends edu.hm.hafner.coverage.Value> modifiedLinesCoverage, List<? extends edu.hm.hafner.coverage.Difference> modifiedLinesCoverageDifference, List<? extends edu.hm.hafner.coverage.Value> modifiedFilesCoverage, List<? extends edu.hm.hafner.coverage.Difference> modifiedFilesCoverageDifference, List<? extends edu.hm.hafner.coverage.Value> indirectCoverageChanges)
    Creates a new instance of CoverageBuildAction.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected io.jenkins.plugins.util.JobAction<? extends io.jenkins.plugins.util.BuildAction<edu.hm.hafner.coverage.Node>>
     
    protected io.jenkins.plugins.util.AbstractXmlStream<edu.hm.hafner.coverage.Node>
     
    formatDelta(Baseline baseline, edu.hm.hafner.coverage.Metric metric)
    Returns a formatted and localized String representation of the delta for the specified metric (with respect to the given baseline).
    formatValue(Baseline baseline, edu.hm.hafner.coverage.Metric metric)
    Returns a formatted and localized String representation of the value for the specified metric (with respect to the given baseline).
    List<edu.hm.hafner.coverage.Difference>
    Returns all available deltas for the specified baseline.
    List<edu.hm.hafner.coverage.Value>
    Returns all available values for the specified baseline.
    Returns the supported baselines.
    protected String
     
    Optional<edu.hm.hafner.coverage.Value>
    getDelta(Baseline baseline, edu.hm.hafner.coverage.Metric metric)
    Returns whether a delta metric for the specified metric exists.
    Returns the associate delta baseline for the specified baseline.
     
     
     
    edu.hm.hafner.util.FilteredLog
     
    io.jenkins.plugins.util.QualityGateResult
     
    Returns the possible reference build that has been used to compute the coverage delta.
    Renders the reference build as an HTML link.
     
     
    getTitle(Baseline baseline)
    Returns the title text for the specified baseline.
    double
    getTrend(Baseline baseline, edu.hm.hafner.coverage.Metric metric)
    Returns whether the trend of the values for the specific metric is positive or negative.
     
    Optional<edu.hm.hafner.coverage.Value>
    getValueForMetric(Baseline baseline, edu.hm.hafner.coverage.Metric metric)
    Returns the value for the specified metric, if available.
    List<edu.hm.hafner.coverage.Value>
    getValues(Baseline baseline)
    Returns all important values for the specified baseline.
    boolean
    Returns whether a delta metric for the specified metric exists.
    boolean
    Returns whether this action represents results with coverage metrics.
    boolean
    hasDelta(Baseline baseline)
    Returns whether a delta metric for the specified baseline exists.
    boolean
    hasDelta(Baseline baseline, edu.hm.hafner.coverage.Metric metric)
    Returns whether a delta metric for the specified metric exists.
    boolean
    hasValue(Baseline baseline, edu.hm.hafner.coverage.Metric metric)
    Returns whether a value for the specified metric exists.
    protected Object
     
     

    Methods inherited from class io.jenkins.plugins.util.BuildAction

    getBuildActionFromHistoryStartingFrom, getOwner, getProjectActions, getResult, onAttached, onLoad

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • CoverageBuildAction

      public CoverageBuildAction(Run<?,?> owner, String id, String optionalName, String icon, edu.hm.hafner.coverage.Node result, io.jenkins.plugins.util.QualityGateResult qualityGateResult, edu.hm.hafner.util.FilteredLog log)
      Creates a new instance of CoverageBuildAction.
      Parameters:
      owner - the associated build that created the statistics
      id - ID (URL) of the results
      optionalName - optional name that overrides the default name of the results
      icon - name of the icon that should be used in actions and views
      result - the coverage tree as a result to persist with this action
      qualityGateResult - status of the quality gates
      log - the logging statements of the recording step
    • CoverageBuildAction

      public CoverageBuildAction(Run<?,?> owner, String id, String optionalName, String icon, edu.hm.hafner.coverage.Node result, io.jenkins.plugins.util.QualityGateResult qualityGateResult, edu.hm.hafner.util.FilteredLog log, String referenceBuildId, List<? extends edu.hm.hafner.coverage.Difference> delta, List<? extends edu.hm.hafner.coverage.Value> modifiedLinesCoverage, List<? extends edu.hm.hafner.coverage.Difference> modifiedLinesCoverageDifference, List<? extends edu.hm.hafner.coverage.Value> modifiedFilesCoverage, List<? extends edu.hm.hafner.coverage.Difference> modifiedFilesCoverageDifference, List<? extends edu.hm.hafner.coverage.Value> indirectCoverageChanges)
      Creates a new instance of CoverageBuildAction.
      Parameters:
      owner - the associated build that created the statistics
      id - ID (URL) of the results
      optionalName - optional name that overrides the default name of the results
      icon - name of the icon that should be used in actions and views
      result - the coverage tree as a result to persist with this action
      qualityGateResult - status of the quality gates
      log - the logging statements of the recording step
      referenceBuildId - the ID of the reference build
      delta - delta of this build's coverages with respect to the reference build
      modifiedLinesCoverage - the coverages filtered by modified lines of the associated change request
      modifiedLinesCoverageDifference - difference between the project coverage and the modified lines coverage of the current build
      modifiedFilesCoverage - the coverages filtered by changed files of the associated change request
      modifiedFilesCoverageDifference - difference between the project coverage and the modified files coverage of the current build
      indirectCoverageChanges - the indirect coverage changes of the associated change request with respect to the reference build
  • Method Details

    • readResolve

      protected Object readResolve()
      Overrides:
      readResolve in class io.jenkins.plugins.util.BuildAction<edu.hm.hafner.coverage.Node>
    • getLog

      public edu.hm.hafner.util.FilteredLog getLog()
    • getQualityGateResult

      public io.jenkins.plugins.util.QualityGateResult getQualityGateResult()
    • getFormatter

      public ElementFormatter getFormatter()
    • getStatistics

      public CoverageStatistics getStatistics()
    • getBaselines

      public List<Baseline> getBaselines()
      Returns the supported baselines.
      Returns:
      all supported baselines
    • hasBaselineResult

      public boolean hasBaselineResult(Baseline baseline)
      Returns whether a delta metric for the specified metric exists.
      Parameters:
      baseline - the baseline to use
      Returns:
      true if a delta is available for the specified metric, false otherwise
    • getDeltaBaseline

      public Baseline getDeltaBaseline(Baseline baseline)
      Returns the associate delta baseline for the specified baseline.
      Parameters:
      baseline - the baseline to get the delta baseline for
      Returns:
      the delta baseline
      Throws:
      NoSuchElementException - if this baseline does not provide a delta baseline
    • getTitle

      public String getTitle(Baseline baseline)
      Returns the title text for the specified baseline.
      Parameters:
      baseline - the baseline to get the title for
      Returns:
      the title
    • getAllValues

      public List<edu.hm.hafner.coverage.Value> getAllValues(Baseline baseline)
      Returns all available values for the specified baseline.
      Parameters:
      baseline - the baseline to get the values for
      Returns:
      the available values
      Throws:
      NoSuchElementException - if this baseline does not provide values
    • getAllDeltas

      public List<edu.hm.hafner.coverage.Difference> getAllDeltas(Baseline baseline)
      Returns all available deltas for the specified baseline.
      Parameters:
      baseline - the baseline to get the deltas for
      Returns:
      the available values
      Throws:
      NoSuchElementException - if this baseline does not provide deltas
    • getValues

      public List<edu.hm.hafner.coverage.Value> getValues(Baseline baseline)
      Returns all important values for the specified baseline.
      Parameters:
      baseline - the baseline to get the values for
      Returns:
      the available values
      Throws:
      NoSuchElementException - if this baseline does not provide values
    • hasCoverage

      public boolean hasCoverage()
      Returns whether this action represents results with coverage metrics. Otherwise, this action represents software metrics.
      Returns:
      true if this action represents coverage metrics, false if this action represents software metrics
    • getValueForMetric

      public Optional<edu.hm.hafner.coverage.Value> getValueForMetric(Baseline baseline, edu.hm.hafner.coverage.Metric metric)
      Returns the value for the specified metric, if available.
      Parameters:
      baseline - the baseline to get the value for
      metric - the metric to get the value for
      Returns:
      the optional value
    • hasDelta

      public boolean hasDelta(Baseline baseline)
      Returns whether a delta metric for the specified baseline exists.
      Parameters:
      baseline - the baseline to use
      Returns:
      true if a delta is available for the specified baseline, false otherwise
    • hasDelta

      public boolean hasDelta(Baseline baseline, edu.hm.hafner.coverage.Metric metric)
      Returns whether a delta metric for the specified metric exists.
      Parameters:
      baseline - the baseline to use
      metric - the metric to check
      Returns:
      true if a delta is available for the specified metric, false otherwise
    • getDelta

      public Optional<edu.hm.hafner.coverage.Value> getDelta(Baseline baseline, edu.hm.hafner.coverage.Metric metric)
      Returns whether a delta metric for the specified metric exists.
      Parameters:
      baseline - the baseline to use
      metric - the metric to check
      Returns:
      true if a delta is available for the specified metric, false otherwise
    • hasValue

      public boolean hasValue(Baseline baseline, edu.hm.hafner.coverage.Metric metric)
      Returns whether a value for the specified metric exists.
      Parameters:
      baseline - the baseline to use
      metric - the metric to check
      Returns:
      true if a value is available for the specified metric, false otherwise
    • formatValue

      public String formatValue(Baseline baseline, edu.hm.hafner.coverage.Metric metric)
      Returns a formatted and localized String representation of the value for the specified metric (with respect to the given baseline).
      Parameters:
      baseline - the baseline to use
      metric - the metric to get the delta for
      Returns:
      the formatted value
    • formatDelta

      public String formatDelta(Baseline baseline, edu.hm.hafner.coverage.Metric metric)
      Returns a formatted and localized String representation of the delta for the specified metric (with respect to the given baseline).
      Parameters:
      baseline - the baseline to use
      metric - the metric to get the delta for
      Returns:
      the delta metric
    • getTrend

      public double getTrend(Baseline baseline, edu.hm.hafner.coverage.Metric metric)
      Returns whether the trend of the values for the specific metric is positive or negative.
      Parameters:
      baseline - the baseline to use
      metric - the metric to check
      Returns:
      a positive value if the trend is positive, a negative value if the trend is negative, or 0 if there is no significant change in the trend
    • getReferenceBuild

      public Optional<Run<?,?>> getReferenceBuild()
      Returns the possible reference build that has been used to compute the coverage delta.
      Returns:
      the reference build, if available
    • getReferenceBuildLink

      public String getReferenceBuildLink()
      Renders the reference build as an HTML link.
      Returns:
      the reference build
      See Also:
    • createXmlStream

      protected io.jenkins.plugins.util.AbstractXmlStream<edu.hm.hafner.coverage.Node> createXmlStream()
      Specified by:
      createXmlStream in class io.jenkins.plugins.util.BuildAction<edu.hm.hafner.coverage.Node>
    • createProjectAction

      protected io.jenkins.plugins.util.JobAction<? extends io.jenkins.plugins.util.BuildAction<edu.hm.hafner.coverage.Node>> createProjectAction()
      Specified by:
      createProjectAction in class io.jenkins.plugins.util.BuildAction<edu.hm.hafner.coverage.Node>
    • getBuildResultBaseName

      protected String getBuildResultBaseName()
      Specified by:
      getBuildResultBaseName in class io.jenkins.plugins.util.BuildAction<edu.hm.hafner.coverage.Node>
    • getTarget

      public CoverageViewModel getTarget()
      Specified by:
      getTarget in interface org.kohsuke.stapler.StaplerProxy
    • getIconFileName

      @NonNull public String getIconFileName()
      Specified by:
      getIconFileName in interface Action
    • getDisplayName

      @NonNull public String getDisplayName()
      Specified by:
      getDisplayName in interface Action
      Specified by:
      getDisplayName in interface ModelObject
    • getUrlName

      @NonNull public String getUrlName()
      Specified by:
      getUrlName in interface Action
    • toString

      public String toString()
      Overrides:
      toString in class Object