After upgrading the the cloudbees-bitbucket-branch-source plugin from 2.1.2 to 2.2.7, loading a pipeline shared library from a pull request no longer works
Before the upgrade, it was possible to access and test code in a PR by appending the following refspec to the global shared library configuration: {code:java} +refs/pull-requests/*/from:refs/remotes/origin/pr/* {code} (as suggested in this guide to [fetching Bitbucket pull requests|https://www.atlassian.com/blog/archives/how-to-fetch-pull-requests]). Using this refspec would allow a developer's PR to be tested using a syntax such as: {code:java} @Library('pipeline-libs@pr/28') // '28' is the PR ID {code}
Since updating the plugin to 2.2.7, this approach is no longer possible, so it is not possible to access a developer's shared library changes from Jenkins before merging the PR.
This is the output from Jenkins: {code:java} Loading library pipeline-libs@pr/28 Attempting to resolve pr/28 from remote references... > git --version # timeout=10 using GIT_SSH to set credentials Jenkins public key > git ls-remote -h -t ssh://g...@stash.forgerock.org:7999/re/jenkins-pipeline-libs.git # timeout=10 Could not find pr/28 in remote references. Pulling heads to local for deep search... > git rev-parse --is-inside-work-tree # timeout=10 Setting origin to ssh://g...@stash.forgerock.org:7999/re/jenkins-pipeline-libs.git > git config remote.origin.url ssh://g...@stash.forgerock.org:7999/re/jenkins-pipeline-libs.git # timeout=10 Fetching origin... Fetching upstream changes from origin > git --version # timeout=10 using GIT_SSH to set credentials Jenkins public key > git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/* +refs/pull-requests/*/from:refs/remotes/origin/pr/* > git rev-parse pr/28^{commit} # timeout=10 > git branch -v --no-abbrev --contains 36750e665cd8155d02b73d339e41ee5cd374599a # timeout=10 Could not find a branch containing commit 36750e665cd8155d02b73d339e41ee5cd374599a ERROR: No version pr/28 found for library pipeline-libs [BFA] Scanning build for known causes... [BFA] No failure causes found [BFA] Done. 0s [Bitbucket] Notifying commit build result [Bitbucket] Build result notified org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: Loading libraries failed {code}
It seems the commit I wish to test (36750e665cd8155d02b73d339e41ee5cd374599a) is correctly identified from the refspec, but no branch exists for this commit (since it is in a PR only) so the job is failing.
Similar issues exist have been resolved for the GitHub branch source plugin - JENKINS-45953 and JENKINS-45830