Why is my BitBucket Multibranch project failing intermittently?

Article ID:360035696932
1 minute readKnowledge base

Issue

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

Resolution

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.

Workaround

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.

References

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