We will occasionally encounter the following error in our BitBucket Multibranch builds:
hudson.plugins.git.GitException: Command "git checkout -f XXXXXXXX" returned status code 128: stdout: stderr: fatal: reference is not a tree: XXXXXXXX
- CloudBees Core on modern cloud platforms - Managed Master
- CloudBees Core on traditional platforms - Client Master
- CloudBees Jenkins Enterprise - Managed Master
- CloudBees Jenkins Platform - Client Master
- CloudBees Jenkins Distribution
- Jenkins LTS
This is the expected behavior of the plugin under certain circumstances. As documented in JENKINS-45997:
When new commits are pushed to a branch which has an open pull request, the pull request hashes are eagerly updated in the database but the refs on disk are not. This behavior has existed unchanged since pull requests were introduced in Stash 1.3.0. If someone views the pull request, then the refs are updated as part of performing a new merge to show an up-to-date diff. Any integration which attempts to use refs/pull-requests/*/from is going to be racy and unreliable because that ref is not eagerly updated.
If you want to get past this issue, the recommended workaround is to enable “Call Can Merge” option in the BitBucket Endpoint configuration section which can be found in Manage Jenkins -> Global Configuration.
- CloudBees Core on traditional platforms - Client Master 22.214.171.124
- BitBucket Branch Source Plugin 2.4.4 and 2.2.12
- JENKINS-45997 BitBucket PRs failing to checkout on initial run after PR updated with new commits