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

Bitbucket branch source plugin fails to checkout pull requests

    Details

    • Similar Issues:

      Description

      The Bitbucket Branch Source Plugin is unable to build pull requests with a dedicated Bitbucket instance after upgrading to the latest version (2.2.12).

      After some tests I was able to verify that broke this functionality was introduced in version 2.2.4 of the plugin. 
      As a workaround it is possible to revert the plugin to 2.2.3.

      The issue is that the plugin tries to pull the branch "branch" by the incorrect branch name "PR-1". The variable scm.branches is also set to the same incorrect value.

      After some search I think I pinpointed it to the following location in the current code: 
      https://github.com/jenkinsci/bitbucket-branch-source-plugin/blob/master/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java#L669

      There was a discussion on the initial commit on the change:
      https://github.com/jenkinsci/bitbucket-branch-source-plugin/pull/63/files

      Kind regards

        Attachments

          Activity

          Hide
          macdrega Joerg Schwaerzler added a comment -

          Same issue here. PR's cannot be built for us (plugin version 2.11) as the BRANCH_NAME 'PR-1' cannot be found. To me this doesn't sound like a minor issue - at least it would be a Major one. Would you mind increasing the priority?

          Show
          macdrega Joerg Schwaerzler added a comment - Same issue here. PR's cannot be built for us (plugin version 2.11) as the BRANCH_NAME 'PR-1' cannot be found. To me this doesn't sound like a minor issue - at least it would be a Major one. Would you mind increasing the priority?
          Hide
          macdrega Joerg Schwaerzler added a comment -

          Workaround which is currently working for me:

          1. Extend the ref spec for the repository to clone by
            +refs/pull-requests/*:refs/remotes/@{remote}/pull-requests/*
          1. Add some lines of code to choose the correct reference in case the build is originated by a pull request, i.e. for loading a shared library this would be something like:
            if (env.CHANGE_ID != null) {
                cpsLibBranch = "refs/remotes/origin/pull-requests/${env.CHANGE_ID}/merge"
            } else {
                cpsLibBranch = env.BRANCH_NAME
            }
            cpsLibId = "cpsLib@${cpsLibBranch}"
            cpsLib = library(cpsLibId)
            
          Show
          macdrega Joerg Schwaerzler added a comment - Workaround which is currently working for me: Extend the ref spec for the repository to clone by +refs/pull-requests/*:refs/remotes/@{remote}/pull-requests/* Add some lines of code to choose the correct reference in case the build is originated by a pull request, i.e. for loading a shared library this would be something like: if (env.CHANGE_ID != null ) { cpsLibBranch = "refs/remotes/origin/pull-requests/${env.CHANGE_ID}/merge" } else { cpsLibBranch = env.BRANCH_NAME } cpsLibId = "cpsLib@${cpsLibBranch}" cpsLib = library(cpsLibId)
          Hide
          lbeeren Lukas Beerens added a comment -

          Just increased the priority.

          Will check your workaround when I am back at work to see if this works. 

          Show
          lbeeren Lukas Beerens added a comment - Just increased the priority. Will check your workaround when I am back at work to see if this works. 

            People

            • Assignee:
              Unassigned
              Reporter:
              lbeeren Lukas Beerens
            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: