Class PipelineStages

java.lang.Object
io.jenkins.plugins.gerritchecksapi.rest.PipelineStages

public final class PipelineStages extends Object
Computes what to report for each stage of a Pipeline build, either as a CheckResult of the run of the build or as a CheckRun of its own.

A stage is reported as a result of the check run of the build it belongs to. Gerrit lists check runs as a flat list, so one run per stage would push a row per stage next to the build; as a result the stage stays inside the run it belongs to. Gerrit derives the badge of a run from the most severe of its results, so a single stage failing still turns the build red without opening Jenkins. Where a stage deserves a row and a status of its own, the check run form is used instead, see StageForm.

The key of a stage is the ID of the run followed by '#' and the ID of the stage's flow node, e.g. 'my-pipeline#7#12'. It identifies the stage in the results of its run, and nests the check run of a stage below the check run of the run.

Every class referencing the Pipeline API is confined to this class. Callers have to check that the workflow-job plugin is installed before calling results(hudson.model.Run<?, ?>, java.lang.String, io.jenkins.plugins.gerritchecksapi.StageReporting) or checkRuns(io.jenkins.plugins.gerritchecksapi.PatchSetId, hudson.model.Run<?, ?>, io.jenkins.plugins.gerritchecksapi.rest.CheckRun, java.lang.String, io.jenkins.plugins.gerritchecksapi.StageReporting), so that the plugin keeps working on instances without Pipeline.

  • Method Details

    • results

      public static List<CheckResult> results(Run<?,?> run, String runUrl, StageReporting reporting)
      Returns one result per stage of the given run, which are to be added to the results of the run itself.
      Returns:
      the results of the stages, or an empty list if the run is not a Pipeline build, does not expose any stage, or is still building and not allowed to report its stages yet
    • checkRuns

      public static List<CheckRun> checkRuns(PatchSetId ps, Run<?,?> run, CheckRun parent, String runUrl, StageReporting reporting)
      Returns one check run per stage of the given run, which are to be added next to the check run of the run itself.
      Parameters:
      parent - the check run of the run itself, which the stages are nested below and whose attempt, description and timestamps they share
      Returns:
      the check runs of the stages, or an empty list if the run is not a Pipeline build, does not expose any stage, or is still building and not allowed to report its stages yet