Motivation

      Commonly people want to run particular stages when they match a specific branch name(s). We would like to make this pattern accessible in the editor.

      Declarative allows the use of when to condition the stage execution like:

      stage('second') {
          agent label:'some-node'
          branch "master" 
          when {
              env.BRANCH == 'master'
          }
      }
      

      However, this isn't exactly what we would consider "friendly" for an editor accessible feature (though when will be supported via a text area) and the developer would have to learn the Script syntax to use it correctly.

      Solution

      We would like to formalise the pattern in a way that is more Editor and user friendly with the introduction of branch. Ideally we could tell from BO if the user has skipped via when or via branch.

      Example - match single branch
      This stage would only be executed if master was the name of the current branch.

      stage('deploy to staging') {
          agent label:'some-node'
          when { branch "master" }
          steps {
              sh './deploy_pr.sh'
          }
      }
      

      Example - match branch name pattern
      This stage would only be executed if the branch name started with feature/.

      stage('deploy to staging') {
          agent label:'some-node'
          when { branch "feature/*" }
          steps {
              sh './deploy_pr.sh'
          }
      }
      

      Example - expression
      You can use an expression to achieve the same thing by:

      stage('deploy to staging') {
          agent label:'some-node'
          when {
      	expression {
      		return BRANCH == 'master';
              }
          }
          steps {
              sh './deploy_pr.sh'
          }
      }
      

          [JENKINS-40370] Run stage when branch name matches

          James Dumay created issue -
          James Dumay made changes -
          Summary Original: Run stage when branch branch New: Run stage when branch name matches
          James Dumay made changes -
          Description Original: *Motivation*

          Commonly people want to run particular stages when they match a specific branch name(s). We would like to make this pattern accessible in the editor.

          Declarative allows the use of {{when}} to condition the stage execution like:
          {code}
          stage('second') {
              agent label:'some-node'
              branch "master"
              when {
                  env.BRANCH == 'master'
              }
          }
          {code}

          However, this isn't exactly editor friendly (though when will be supported via a text area) and the developer would have to jump into the Script syntax.

          *Solution*

          We would like to formalise the pattern in a way that is more Editor and user friendly.

          *Example - match single branch*
          {code}
          stage('deploy') {
              agent label:'some-node'
              branch "master"
              steps {
                  sh './deploy.sh'
              }
          }
          {code}

          *Example - match branch name pattern*
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              branch "feature/*"
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}
          New: *Motivation*

          Commonly people want to run particular stages when they match a specific branch name(s). We would like to make this pattern accessible in the editor.

          Declarative allows the use of {{when}} to condition the stage execution like:
          {code}
          stage('second') {
              agent label:'some-node'
              branch "master"
              when {
                  env.BRANCH == 'master'
              }
          }
          {code}

          However, this isn't exactly editor friendly (though when will be supported via a text area) and the developer would have to learn the Script syntax to use.

          *Solution*

          We would like to formalise the pattern in a way that is more Editor and user friendly.

          *Example - match single branch*
          {code}
          stage('deploy') {
              agent label:'some-node'
              branch "master"
              steps {
                  sh './deploy.sh'
              }
          }
          {code}

          *Example - match branch name pattern*
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              branch "feature/*"
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}
          James Dumay made changes -
          Description Original: *Motivation*

          Commonly people want to run particular stages when they match a specific branch name(s). We would like to make this pattern accessible in the editor.

          Declarative allows the use of {{when}} to condition the stage execution like:
          {code}
          stage('second') {
              agent label:'some-node'
              branch "master"
              when {
                  env.BRANCH == 'master'
              }
          }
          {code}

          However, this isn't exactly editor friendly (though when will be supported via a text area) and the developer would have to learn the Script syntax to use.

          *Solution*

          We would like to formalise the pattern in a way that is more Editor and user friendly.

          *Example - match single branch*
          {code}
          stage('deploy') {
              agent label:'some-node'
              branch "master"
              steps {
                  sh './deploy.sh'
              }
          }
          {code}

          *Example - match branch name pattern*
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              branch "feature/*"
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}
          New: *Motivation*

          Commonly people want to run particular stages when they match a specific branch name(s). We would like to make this pattern accessible in the editor.

          Declarative allows the use of {{when}} to condition the stage execution like:
          {code}
          stage('second') {
              agent label:'some-node'
              branch "master"
              when {
                  env.BRANCH == 'master'
              }
          }
          {code}

          However, this isn't exactly editor friendly (though when will be supported via a text area) and the developer would have to learn the Script syntax to use.

          *Solution*

          We would like to formalise the pattern in a way that is more Editor and user friendly.

          *Example - match single branch*
          This stage would only be executed if {{master}} was the name of the current branch.
          {code}
          stage('deploy') {
              agent label:'some-node'
              branch "master"
              steps {
                  sh './deploy.sh'
              }
          }
          {code}

          *Example - match branch name pattern*
          This stage would only be executed if the branch name started with {{feature/}}
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              branch "feature/*"
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}
          James Dumay made changes -
          Description Original: *Motivation*

          Commonly people want to run particular stages when they match a specific branch name(s). We would like to make this pattern accessible in the editor.

          Declarative allows the use of {{when}} to condition the stage execution like:
          {code}
          stage('second') {
              agent label:'some-node'
              branch "master"
              when {
                  env.BRANCH == 'master'
              }
          }
          {code}

          However, this isn't exactly editor friendly (though when will be supported via a text area) and the developer would have to learn the Script syntax to use.

          *Solution*

          We would like to formalise the pattern in a way that is more Editor and user friendly.

          *Example - match single branch*
          This stage would only be executed if {{master}} was the name of the current branch.
          {code}
          stage('deploy') {
              agent label:'some-node'
              branch "master"
              steps {
                  sh './deploy.sh'
              }
          }
          {code}

          *Example - match branch name pattern*
          This stage would only be executed if the branch name started with {{feature/}}
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              branch "feature/*"
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}
          New: *Motivation*

          Commonly people want to run particular stages when they match a specific branch name(s). We would like to make this pattern accessible in the editor.

          Declarative allows the use of {{when}} to condition the stage execution like:
          {code}
          stage('second') {
              agent label:'some-node'
              branch "master"
              when {
                  env.BRANCH == 'master'
              }
          }
          {code}

          However, this isn't exactly editor friendly (though {{when}} will be supported via a text area) and the developer would have to learn the Script syntax to use.

          *Solution*

          We would like to formalise the pattern in a way that is more Editor and user friendly.

          *Example - match single branch*
          This stage would only be executed if {{master}} was the name of the current branch.
          {code}
          stage('deploy') {
              agent label:'some-node'
              branch "master"
              steps {
                  sh './deploy.sh'
              }
          }
          {code}

          *Example - match branch name pattern*
          This stage would only be executed if the branch name started with {{feature/}}
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              branch "feature/*"
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}
          James Dumay made changes -
          Description Original: *Motivation*

          Commonly people want to run particular stages when they match a specific branch name(s). We would like to make this pattern accessible in the editor.

          Declarative allows the use of {{when}} to condition the stage execution like:
          {code}
          stage('second') {
              agent label:'some-node'
              branch "master"
              when {
                  env.BRANCH == 'master'
              }
          }
          {code}

          However, this isn't exactly editor friendly (though {{when}} will be supported via a text area) and the developer would have to learn the Script syntax to use.

          *Solution*

          We would like to formalise the pattern in a way that is more Editor and user friendly.

          *Example - match single branch*
          This stage would only be executed if {{master}} was the name of the current branch.
          {code}
          stage('deploy') {
              agent label:'some-node'
              branch "master"
              steps {
                  sh './deploy.sh'
              }
          }
          {code}

          *Example - match branch name pattern*
          This stage would only be executed if the branch name started with {{feature/}}
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              branch "feature/*"
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}
          New: *Motivation*

          Commonly people want to run particular stages when they match a specific branch name(s). We would like to make this pattern accessible in the editor.

          Declarative allows the use of {{when}} to condition the stage execution like:
          {code}
          stage('second') {
              agent label:'some-node'
              branch "master"
              when {
                  env.BRANCH == 'master'
              }
          }
          {code}

          However, this isn't exactly what we would consider "friendly" for an editor accessible feature (though {{when}} will be supported via a text area) and the developer would have to learn the Script syntax to use it correctly.

          *Solution*

          We would like to formalise the pattern in a way that is more Editor and user friendly.

          *Example - match single branch*
          This stage would only be executed if {{master}} was the name of the current branch.
          {code}
          stage('deploy') {
              agent label:'some-node'
              branch "master"
              steps {
                  sh './deploy.sh'
              }
          }
          {code}

          *Example - match branch name pattern*
          This stage would only be executed if the branch name started with {{feature/}}
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              branch "feature/*"
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}
          James Dumay made changes -
          Description Original: *Motivation*

          Commonly people want to run particular stages when they match a specific branch name(s). We would like to make this pattern accessible in the editor.

          Declarative allows the use of {{when}} to condition the stage execution like:
          {code}
          stage('second') {
              agent label:'some-node'
              branch "master"
              when {
                  env.BRANCH == 'master'
              }
          }
          {code}

          However, this isn't exactly what we would consider "friendly" for an editor accessible feature (though {{when}} will be supported via a text area) and the developer would have to learn the Script syntax to use it correctly.

          *Solution*

          We would like to formalise the pattern in a way that is more Editor and user friendly.

          *Example - match single branch*
          This stage would only be executed if {{master}} was the name of the current branch.
          {code}
          stage('deploy') {
              agent label:'some-node'
              branch "master"
              steps {
                  sh './deploy.sh'
              }
          }
          {code}

          *Example - match branch name pattern*
          This stage would only be executed if the branch name started with {{feature/}}
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              branch "feature/*"
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}
          New: *Motivation*

          Commonly people want to run particular stages when they match a specific branch name(s). We would like to make this pattern accessible in the editor.

          Declarative allows the use of {{when}} to condition the stage execution like:
          {code}
          stage('second') {
              agent label:'some-node'
              branch "master"
              when {
                  env.BRANCH == 'master'
              }
          }
          {code}

          However, this isn't exactly what we would consider "friendly" for an editor accessible feature (though {{when}} will be supported via a text area) and the developer would have to learn the Script syntax to use it correctly.

          *Solution*

          We would like to formalise the pattern in a way that is more Editor and user friendly.

          *Example - match single branch*
          This stage would only be executed if {{master}} was the name of the current branch.
          {code}
          stage('deploy') {
              agent label:'some-node'
              branch "master"
              steps {
                  sh './deploy.sh'
              }
          }
          {code}

          *Example - match branch name pattern*
          This stage would only be executed if the branch name started with {{feature/}}.
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              branch "feature/*"
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}
          James Dumay made changes -
          Description Original: *Motivation*

          Commonly people want to run particular stages when they match a specific branch name(s). We would like to make this pattern accessible in the editor.

          Declarative allows the use of {{when}} to condition the stage execution like:
          {code}
          stage('second') {
              agent label:'some-node'
              branch "master"
              when {
                  env.BRANCH == 'master'
              }
          }
          {code}

          However, this isn't exactly what we would consider "friendly" for an editor accessible feature (though {{when}} will be supported via a text area) and the developer would have to learn the Script syntax to use it correctly.

          *Solution*

          We would like to formalise the pattern in a way that is more Editor and user friendly.

          *Example - match single branch*
          This stage would only be executed if {{master}} was the name of the current branch.
          {code}
          stage('deploy') {
              agent label:'some-node'
              branch "master"
              steps {
                  sh './deploy.sh'
              }
          }
          {code}

          *Example - match branch name pattern*
          This stage would only be executed if the branch name started with {{feature/}}.
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              branch "feature/*"
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}
          New: *Motivation*

          Commonly people want to run particular stages when they match a specific branch name(s). We would like to make this pattern accessible in the editor.

          Declarative allows the use of {{when}} to condition the stage execution like:
          {code}
          stage('second') {
              agent label:'some-node'
              branch "master"
              when {
                  env.BRANCH == 'master'
              }
          }
          {code}

          However, this isn't exactly what we would consider "friendly" for an editor accessible feature (though {{when}} will be supported via a text area) and the developer would have to learn the Script syntax to use it correctly.

          *Solution*

          We would like to formalise the pattern in a way that is more Editor and user friendly with the introduction of {{branch}}. Ideally we could tell from BO if the user has skipped via {{when}} or via {{branch}}

          *Example - match single branch*
          This stage would only be executed if {{master}} was the name of the current branch.
          {code}
          stage('deploy') {
              agent label:'some-node'
              branch "master"
              steps {
                  sh './deploy.sh'
              }
          }
          {code}

          *Example - match branch name pattern*
          This stage would only be executed if the branch name started with {{feature/}}.
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              branch "feature/*"
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}
          James Dumay made changes -
          Description Original: *Motivation*

          Commonly people want to run particular stages when they match a specific branch name(s). We would like to make this pattern accessible in the editor.

          Declarative allows the use of {{when}} to condition the stage execution like:
          {code}
          stage('second') {
              agent label:'some-node'
              branch "master"
              when {
                  env.BRANCH == 'master'
              }
          }
          {code}

          However, this isn't exactly what we would consider "friendly" for an editor accessible feature (though {{when}} will be supported via a text area) and the developer would have to learn the Script syntax to use it correctly.

          *Solution*

          We would like to formalise the pattern in a way that is more Editor and user friendly with the introduction of {{branch}}. Ideally we could tell from BO if the user has skipped via {{when}} or via {{branch}}

          *Example - match single branch*
          This stage would only be executed if {{master}} was the name of the current branch.
          {code}
          stage('deploy') {
              agent label:'some-node'
              branch "master"
              steps {
                  sh './deploy.sh'
              }
          }
          {code}

          *Example - match branch name pattern*
          This stage would only be executed if the branch name started with {{feature/}}.
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              branch "feature/*"
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}
          New: *Motivation*

          Commonly people want to run particular stages when they match a specific branch name(s). We would like to make this pattern accessible in the editor.

          Declarative allows the use of {{when}} to condition the stage execution like:
          {code}
          stage('second') {
              agent label:'some-node'
              branch "master"
              when {
                  env.BRANCH == 'master'
              }
          }
          {code}

          However, this isn't exactly what we would consider "friendly" for an editor accessible feature (though {{when}} will be supported via a text area) and the developer would have to learn the Script syntax to use it correctly.

          *Solution*

          We would like to formalise the pattern in a way that is more Editor and user friendly with the introduction of {{branch}}. Ideally we could tell from BO if the user has skipped via {{when}} or via {{branch}}.

          *Example - match single branch*
          This stage would only be executed if {{master}} was the name of the current branch.
          {code}
          stage('deploy') {
              agent label:'some-node'
              branch "master"
              steps {
                  sh './deploy.sh'
              }
          }
          {code}

          *Example - match branch name pattern*
          This stage would only be executed if the branch name started with {{feature/}}.
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              branch "feature/*"
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}
          James Dumay made changes -
          Description Original: *Motivation*

          Commonly people want to run particular stages when they match a specific branch name(s). We would like to make this pattern accessible in the editor.

          Declarative allows the use of {{when}} to condition the stage execution like:
          {code}
          stage('second') {
              agent label:'some-node'
              branch "master"
              when {
                  env.BRANCH == 'master'
              }
          }
          {code}

          However, this isn't exactly what we would consider "friendly" for an editor accessible feature (though {{when}} will be supported via a text area) and the developer would have to learn the Script syntax to use it correctly.

          *Solution*

          We would like to formalise the pattern in a way that is more Editor and user friendly with the introduction of {{branch}}. Ideally we could tell from BO if the user has skipped via {{when}} or via {{branch}}.

          *Example - match single branch*
          This stage would only be executed if {{master}} was the name of the current branch.
          {code}
          stage('deploy') {
              agent label:'some-node'
              branch "master"
              steps {
                  sh './deploy.sh'
              }
          }
          {code}

          *Example - match branch name pattern*
          This stage would only be executed if the branch name started with {{feature/}}.
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              branch "feature/*"
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}
          New: *Motivation*

          Commonly people want to run particular stages when they match a specific branch name(s). We would like to make this pattern accessible in the editor.

          Declarative allows the use of {{when}} to condition the stage execution like:
          {code}
          stage('second') {
              agent label:'some-node'
              branch "master"
              when {
                  env.BRANCH == 'master'
              }
          }
          {code}

          However, this isn't exactly what we would consider "friendly" for an editor accessible feature (though {{when}} will be supported via a text area) and the developer would have to learn the Script syntax to use it correctly.

          *Solution*

          We would like to formalise the pattern in a way that is more Editor and user friendly with the introduction of {{branch}}. Ideally we could tell from BO if the user has skipped via {{when}} or via {{branch}}.

          *Example - match single branch*
          This stage would only be executed if {{master}} was the name of the current branch.
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              when { branch "master" }
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}

          *Example - match branch name pattern*
          This stage would only be executed if the branch name started with {{feature/}}.
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              when { branch "feature/*" }
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}
          James Dumay made changes -
          Description Original: *Motivation*

          Commonly people want to run particular stages when they match a specific branch name(s). We would like to make this pattern accessible in the editor.

          Declarative allows the use of {{when}} to condition the stage execution like:
          {code}
          stage('second') {
              agent label:'some-node'
              branch "master"
              when {
                  env.BRANCH == 'master'
              }
          }
          {code}

          However, this isn't exactly what we would consider "friendly" for an editor accessible feature (though {{when}} will be supported via a text area) and the developer would have to learn the Script syntax to use it correctly.

          *Solution*

          We would like to formalise the pattern in a way that is more Editor and user friendly with the introduction of {{branch}}. Ideally we could tell from BO if the user has skipped via {{when}} or via {{branch}}.

          *Example - match single branch*
          This stage would only be executed if {{master}} was the name of the current branch.
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              when { branch "master" }
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}

          *Example - match branch name pattern*
          This stage would only be executed if the branch name started with {{feature/}}.
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              when { branch "feature/*" }
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}
          New: *Motivation*

          Commonly people want to run particular stages when they match a specific branch name(s). We would like to make this pattern accessible in the editor.

          Declarative allows the use of {{when}} to condition the stage execution like:
          {code}
          stage('second') {
              agent label:'some-node'
              branch "master"
              when {
                  env.BRANCH == 'master'
              }
          }
          {code}

          However, this isn't exactly what we would consider "friendly" for an editor accessible feature (though {{when}} will be supported via a text area) and the developer would have to learn the Script syntax to use it correctly.

          *Solution*

          We would like to formalise the pattern in a way that is more Editor and user friendly with the introduction of {{branch}}. Ideally we could tell from BO if the user has skipped via {{when}} or via {{branch}}.

          *Example - match single branch*
          This stage would only be executed if {{master}} was the name of the current branch.
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              when { branch "master" }
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}

          *Example - match branch name pattern*
          This stage would only be executed if the branch name started with {{feature/}}.
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              when { branch "feature/*" }
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}

          *Example - expression*
          You can use an {{expression}} to achieve the same thing by:
          {code}
          stage('deploy to staging') {
              agent label:'some-node'
              when {
          expression {
                         return BRANCH == 'master';
                  }
              }
              steps {
                  sh './deploy_pr.sh'
              }
          }
          {code}

            rsandell rsandell
            jamesdumay James Dumay
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: