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

CHANGE_TARGET is not set to the target branch

XMLWordPrintable

      CHANGE_TARGET is intended to represent the "target branch" of a change request – i.e., the target branch that the change will be merged into if approved and submitted. Currently this gets set to the change ref. These variables were printed using sh "env".

       

      // git push gerrit HEAD:refs/for/master
      CHANGE_TITLE=53/106353/19
      CHANGE_TARGET=53/106353/19
      CHANGE_ID=C-106353/19
      CHANGE_URL=https://gerrit.server/106353
      GERRIT_BRANCH=master
      

      In this case, GERRIT_BRANCH represents the target branch, but because it's not set in CHANGE_TARGET, we cannot use the changeRequest conditional in a declarative pipeline:

      pipeline {
        stage("for master only") {
          when {
            changeRequest target: 'master'  // will not work
          }
        }
      }
      

            lucamilanesio Luca Domenico Milanesio
            jhansche Joe Hansche
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: