Class ConsolidatedRuns

java.lang.Object
se.diabol.jenkins.pipeline.consolidated.ConsolidatedRuns
All Implemented Interfaces:
Saveable

@Extension public class ConsolidatedRuns extends Object implements Saveable
Runs the consolidated pipelines of the views: the pipelines of a view a few at a time. A run takes the view's pipelines in the order the view is configured in and cuts them into batches of the configured size. It builds the first job of every pipeline of a batch, waits until all of them have come to an end, sleeps for the configured time and goes on with the next batch, whatever the outcome of the last one.

A pipeline has come to an end when nothing of it is running or waiting in the queue any more, blocked items included, and that has been so for a few seconds: the whole chain downstream of the first build counts, or for a Pipeline job the run with the runs it started, as the view shows it. So a batch leaves the agents idle before the next one starts, and jobs that wait for the others to finish, such as a clean-up that the builds of the batch block, get their turn in between. A pipeline that waits for a person at an input step holds its batch until someone answers or the run is stopped; a manual step that nobody triggers does not.

The runs are kept in $JENKINS_HOME/se.diabol.jenkins.pipeline.consolidated.ConsolidatedRuns.xml, the one going on or the last one per view, so that a run goes on after a restart and a view shows how its last run went. They are kept apart from the views because a view is a part of its owner's configuration, which a seed job replaces while a run is going.

Threads: one lock guards the runs. Readers never take it; they get the copy that was published after the last change, because the view model is computed inside the model cache and the cache is emptied from inside the queue.

  • Constructor Details

    • ConsolidatedRuns

      public ConsolidatedRuns()
  • Method Details

    • get

      public static ConsolidatedRuns get()
    • of

      public ConsolidatedRun of(String viewKey)
      The run of the view that is going on, or else its last one, or null; a copy that nothing changes any more.
    • start

      public ConsolidatedRun start(String viewKey, String viewName, List<ConsolidatedRuns.Target> targets, int concurrentPipelines, int sleepSeconds, String userId, String userName) throws PipelineException
      Starts a run of the view and its first batch. The caller has checked that the user may build the targets.
      Throws:
      PipelineException - when a run of the view is going on already, or there is nothing to run
    • stop

      public ConsolidatedRun stop(String viewKey, String userName) throws PipelineException
      Stops the view's run: no further batch starts. The pipelines that are running go on, and the run ends when they have. Stopping a run that is stopping already gives up waiting for them and ends the run at once, which is the way out when a pipeline can never end, such as one whose job waits in the queue for an agent that is gone.
      Throws:
      PipelineException - when no run of the view is going on
    • save

      public void save()
      Specified by:
      save in interface Saveable