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

No way to merge with target branch for a pull request


      When running with the following Jenkinsfile:

      node {
          checkout scm
          echo "My branch is: ${env.BRANCH_NAME}"
          echo "My target branch is: ${env.CHANGE_TARGET}"

      The following is printed out:

      [Pipeline] echo
      My branch is: PR-4
      [Pipeline] echo
      My target branch is: null

      I thought CHANGE_TARGET would contain the target branch but apparently I am mistaken? The setup I was thinking of is the following:

      Pull request (from a fork):

      • merge with target branch
      • run test suite

      Pull request get merged into a release branch

      • run test suite
      • build and deploy/publish an artifact

      But it seems to be impossible to declare this in a single folder, I would also be happy to do this in two folders, but that seems impossible as well?

      If there was a way to differentiate between a PR and a regular build AND get the target branch for a PR, I could keep Jenkins config to the bare minimum; the link to a repo and let multibranch / pr discovery do all the rest.

      Am I maybe missing something obvious here or am I trying to do the impossible? I combed through the documentation for the plugin and the available docs and snippet generator for the pipeline scripts but came up empty.

            amuniz Antonio Muñiz
            kevin_smets Kevin Smets
            0 Vote for this issue
            3 Start watching this issue