I'd like to create two stages, where if one runs the other doesn't - effectively and `if-else`.

      Right now I'd have to do something like this:

      stages {
          stage ('Full Build') {
              when {
                  expression { return params.FORCE_FULL_BUILD }
              }
          }
      
          stage ('Incremental Build') {
              when {
                  expression { return !params.FORCE_FULL_BUILD }
              }
          }
      }
      

      For simple expressions, that's no problem. For complex expressions it gets tiresome.

      The `when {}` block needs a way to indicate `else`. This could be done (when combined with a logical `not` condition) by have a `stage` condition. Like so:

      stages {
          stage ('Full Build') {
              when {
                  expression { return params.FORCE_FULL_BUILD }
              }
          }
      
          stage ('Incremental Build') {
              when {
                  not { stage 'Full Build' }
              }
          }
      }
      

      This would also allow for stages to depend on previous stages in a clear fashion. For example:

      stages {
          stage ('Full Build') {
              when {
                  expression { return params.FORCE_FULL_BUILD }
              }
          }
      
          stage ('Incremental Build') {
              when {
                  not { stage 'Full Build' }
              }
          }
      
          stage ('Full Tests') {
              when {
                  stage 'Full Build' }
              }
          }
      
          stage ('Incremental Tests') {
              when {
                  stage 'Incremental Build' }
              }
          }
      }
      

          [JENKINS-41187] Stage "when" should have "stage" condition

          Liam Newman created issue -
          Liam Newman made changes -
          Link New: This issue relates to JENKINS-41185 [ JENKINS-41185 ]
          James Dumay made changes -
          Summary Original: [Declarative Pipeline] Stage "when" should have "stage" condition New: Stage "when" should have "stage" condition
          James Dumay made changes -
          Epic Link New: JENKINS-45426 [ 183594 ]
          Andrew Bayer made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Andrew Bayer made changes -
          Remote Link New: This issue links to "new plugin repo (initial) (Web Link)" [ 17831 ]
          Andrew Bayer made changes -
          Assignee Original: Andrew Bayer [ abayer ]

            Unassigned Unassigned
            bitwiseman Liam Newman
            Votes:
            11 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated: