Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-61101

Mutually exclusive stages in declarative pipeline


      There have been a few cases where I've needed to define a set of mutually exclusive stages of which only one should execute. Right now this can be accomplished with a parallel block containing stages with inter-related when conditions, but this is annoying to manage. I propose adding a new switch block to stage.


      stage ("Do It") {
          switch {
              stage("Stage A") {
                  when { expression { return conditionA } }
                  steps { ... }
              stage("Stage B") {
                   when { expression { return conditionB } }
                   steps { ... }
              stage("Stage C") {
                  steps { ... }

      This means "If condition A, do Stage A. Else if condition B, do Stage B. Else, do Stage C." switch would be at the same level as stagesparallel, and matrix today. This allows Blue Ocean to clearly display the mutually exclusive stages (probably in a vertical arrangement, like it does for parallel).

            bitwiseman Liam Newman
            rittneje Jesse Rittner
            0 Vote for this issue
            3 Start watching this issue