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

PRs failing to build due to missing branch

XMLWordPrintable

      We have attached our repo to jenkins using the multi branch plugin. Our workflow is as follows:

      1. developer creates a fork of repo
      2. makes new $branch in fork and edits code
      3. makes pull request to upstream to be pulled to $branch on upstream
      4. jenkins picks up on the pull request and starts building and doing tests

      When the pull request to upstream is made, $branch does not exist yet until it has been accepted. This is a feature of Bitbucket which allows this.

      When we updated from version 2.1.1 to 2.2.3 of Bitbucket Branch Source Plugin, the workflow above did not work anymore. The pipeline log is as follows:

      Branch indexing
      Cannot find the branch branch-name
      ERROR: Could not determine exact tip revision of PR-1234; falling back to nondeterministic checkout
      Checking out git https://bitbucket.org/username/reponame.git to read Jenkinsfile
      Cloning the remote Git repository
      Cloning with configured refspecs honoured and without tags
      Cloning repository https://bitbucket.org/username/reponame.git
      > git init /var/jenkins_home/workspace/pipeline_name # timeout=60
      Fetching upstream changes from https://bitbucket.org/username/reponame.git
      > git --version # timeout=60
      using GIT_ASKPASS to set credentials 
      > git fetch --no-tags --progress https://bitbucket.org/username/reponame.git +refs/heads/branch-name:refs/remotes/origin/PR-1234
      > git config remote.origin.url https://bitbucket.org/username/reponame.git # timeout=60
      > git config --add remote.origin.fetch +refs/heads/branch-name:refs/remotes/origin/PR-1234 # timeout=60
      > git config remote.origin.url https://bitbucket.org/username/reponame.git # timeout=60
      Fetching without tags
      Fetching upstream changes from https://bitbucket.org/username/reponame.git
      using GIT_ASKPASS to set credentials 
      > git fetch --no-tags --progress https://bitbucket.org/username/reponame.git +refs/heads/branch-name:refs/remotes/origin/PR-1234
      > git rev-parse branch-name^{commit} # timeout=60
      > git rev-parse refs/remotes/origin/branch-name^{commit} # timeout=60
      > git rev-parse branch-name^{commit} # timeout=60
      ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
      Finished: FAILURE
      

      When I create the branch on upstream manually, the build does work and is being correctly build from the fork.

            Unassigned Unassigned
            rpa_reus Rob Reus
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: