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

Mutually exclusive stages in declarative pipeline

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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).

        Attachments

          Activity

          Hide
          bitwiseman Liam Newman added a comment -

          I love this syntax. Very elegant.

          I'm not sure exactly how it should be implemented yet.

          I agree it would be nice to have blue ocean display these vertically, but that would mean implementing/exposing the switch as though it were a parallel with would limit where it could be used - for instance then we couldn't have a switch inside a switch.

          Show
          bitwiseman Liam Newman added a comment - I love this syntax. Very elegant. I'm not sure exactly how it should be implemented yet. I agree it would be nice to have blue ocean display these vertically, but that would mean implementing/exposing the switch as though it were a parallel with would limit where it could be used - for instance then we couldn't have a switch inside a switch.

            People

            Assignee:
            bitwiseman Liam Newman
            Reporter:
            rittneje Jesse Rittner
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: