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

[Declarative Pipeline] Stage "when" should have logical operator steps (and, or, not, all, any)

      The last change to the stage `when {}` block changed to using items like `branch` and `expression`.

      Multiple items cannot be used in the same when block. This makes sense because it would unclear whether those items should be "A or B", or if they should be "A and B".

      The `when` block should support logical blocks such as `and {}`, `or {}`, `not {}` to allow combining other conditions in a clear fashion.

      For example, when branch is master or parameter "FORCE_FULL_BUILD" is true:

      stage ('Build') {
          when {
              or {
                  branch 'master'
                  expression { return params.FORCE_FULL_BUILD }
              }
          }
      }
      

      Alternative: use `all {}` instead of `and`, and use `any {}` instead of `or {}`:

      stage ('Build') {
          when {
              any {
                  branch 'master'
                  expression { return params.FORCE_FULL_BUILD }
              }
          }
      }
      

          [JENKINS-41185] [Declarative Pipeline] Stage "when" should have logical operator steps (and, or, not, all, any)

          Liam Newman created issue -
          Liam Newman made changes -
          Summary Original: [Declarative Pipeline] Stage when should have logical operator steps (and, or, not, all, any) New: [Declarative Pipeline] Stage "when" should have logical operator steps (and, or, not, all, any)
          Liam Newman made changes -
          Link New: This issue relates to JENKINS-41187 [ JENKINS-41187 ]
          Andrew Bayer made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]

          Andrew Bayer added a comment -

          Starting preliminary work on this, but it won't land 'til post-1.0.

          Andrew Bayer added a comment - Starting preliminary work on this, but it won't land 'til post-1.0.

          Andrew Bayer added a comment -

          Andrew Bayer added a comment - Work-in-progress for post-1.0 PR up at https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/99
          Andrew Bayer made changes -
          Remote Link New: This issue links to "PR #99 (Web Link)" [ 15316 ]
          Andrew Bayer made changes -
          Remote Link Original: This issue links to "PR #99 (Web Link)" [ 15316 ]
          Andrew Bayer made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]

          Andrew Bayer added a comment -

          Andrew Bayer added a comment - Real PR up at https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/125
          Andrew Bayer made changes -
          Remote Link New: This issue links to "PR #125 (Web Link)" [ 15485 ]

            abayer Andrew Bayer
            bitwiseman Liam Newman
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: