jenkinsjenkins-job-dsldelivery-pipeline

How can a final-job-to-be-displayed in a Jenkins Delivery Pipeline view be configured using the Job DSL?


The setup

How to do it through the UI

On the View configuration page, there's a setting for the last displayed job in the view:

Pipelines
  Components
    Name                    [text field here]
    Initial Job             [text field here]
    Final Job (optional)    [text field here]

When a final Job is given, the the view does not display any jobs that may be triggered by that job, i.e. as the label implies, this job is the last job displayed in this view.

The question

How can I configure this final job name, using the Job DSL?


Solution

  • Setting the last job is currently not supported by the built-in DSL. But you can use a Configure Block to generate any configuration:

    deliveryPipelineView('example') {
      pipelines {
        component('one', 'foo1')
        component('two', 'foo2')
      }
      configure { view ->
        def components = view / componentSpecs
        components.'se.diabol.jenkins.pipeline.DeliveryPipelineView_-ComponentSpec'[0] << lastJob('bar1')
        components.'se.diabol.jenkins.pipeline.DeliveryPipelineView_-ComponentSpec'[1] << lastJob('bar2')
      }
    }