Why is my BitBucket Multibranch project failing intermittently?


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:
stderr: fatal: reference is not a tree: XXXXXXXX



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.

Tested product/plugin versions


  • JENKINS-45997 BitBucket PRs failing to checkout on initial run after PR updated with new commits

Have more questions?


Please sign in to leave a comment.