Bitbucket failing to checkout after PR gets new commits

Article ID:360055462071
1 minute readKnowledge base


Updating an existing Pull Request with additional commits leads to broken builds of the Pull Request, because Jenkins tries to check out a non-existent ref in git.

You will see an error in your build similar to this:

[Bitbucket] Build result notified
hudson.plugins.git.GitException: Command "git checkout -f *****************************" returned status code 128:
stderr: fatal: reference is not a tree: *****************************

	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$800(
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(
Caused: hudson.plugins.git.GitException: Could not checkout *****************************
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(
	at jenkins.plugins.git.MergeWithGitSCMExtension.checkout(
	at jenkins.plugins.git.MergeWithGitSCMExtension.decorateRevisionToBuild(
	at hudson.plugins.git.GitSCM.determineRevisionToBuild(
	at hudson.plugins.git.GitSCM.checkout(
	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(
	at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(
	at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(
	at hudson.model.ResourceController.execute(
Finished: FAILURE


In investigations this issue is limited to environments that use Bitbucket Enterprise. This is caused by a missing configuration in Jenkins.

  1. Navigate to Manage Jenkins -> Configure System -> Bitbucket Endpoints

  2. Under your Bitbucket Server settings, locate the Call Can Merge checkbox.

  3. This setting will need to be toggled on.

Tested product/plugin versions

Bitbucket Branch Source Plugin version 2.5.0


Reported Issue JENKINS-45997