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

CHANGE_BRANCH for pull-request should return source branch, not pull-request pseudo-branch

    Details

    • Similar Issues:

      Description

      From a pull-request on stash/Bitbucket - I'm trying to fetch the original source-branch.  The pull request is from `feature/jenkins_phoenix` -> `master`.  I can retrieve the target branch (main) but other methods seem to return the PR-XX pseudo-branch. None of the environment branched
       

      details = checkout(scm);
      sh "echo ${details.GIT_BRANCH} ${details.CHANGE_TARGET} ${details.CHANGE_ID} ${details.CHANGE_BRANCH} ${details.CHANGE_SOURCE} ${details.CHANGE_FORK}"
      > PR-63 null null null null null
      sh "echo ${env.BRANCH_NAME} ${env.CHANGE_TARGET} ${env.CHANGE_ID} ${env.CHANGE_BRANCH} ${env.CHANGE_SOURCE} ${env.CHANGE_FORK}"
      > PR-63 master 63 PR-63 null null

      Multiple stack overflow queries https://stackoverflow.com/questions/49151984 and https://stackoverflow.com/questions/48868953 suggest that CHANGE_BRANCH is the right answer, so I suspect the Bitbucket branch source plugin is not retrieving this correctly. 

      This set up is using the Bitbucket Team/Project "multibranch" builder.

      For this test I have explicitly disabled the option in the git plugin to build against the result of merging the source-branch into the target branch, so the selected commit is indeed exactly from the source-branch.

      I do however intend to reinstate the merge-branch in the future - and for my examples I need to know the true branch name that triggered the build, not guess it via git inference.

      Full (redacted) env dump attached.

      I think this is in essence similar to the abandoned issue JENKINS-41104 that was not resolved.

      Let me know if there is more information that you need, or other diagnostics I could dump.

        Attachments

          Activity

          whitty Greg Whiteley created issue -
          stephenconnolly Stephen Connolly made changes -
          Field Original Value New Value
          Assignee Stephen Connolly [ stephenconnolly ]

            People

            • Assignee:
              Unassigned
              Reporter:
              whitty Greg Whiteley
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: