Issue
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:
stdout:
stderr: fatal: reference is not a tree: *****************************
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1924)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$800(CliGitAPIImpl.java:71)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:2214)
Caused: hudson.plugins.git.GitException: Could not checkout *****************************
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:2237)
at jenkins.plugins.git.MergeWithGitSCMExtension.checkout(MergeWithGitSCMExtension.java:146)
at jenkins.plugins.git.MergeWithGitSCMExtension.decorateRevisionToBuild(MergeWithGitSCMExtension.java:112)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:1023)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1116)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:109)
at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:130)
at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:120)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:246)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:405)
Finished: FAILURE
Resolution
In investigations this issue is limited to environments that use Bitbucket Enterprise. This is caused by a missing configuration in Jenkins.
-
Navigate to
Manage Jenkins -> Configure System -> Bitbucket Endpoints
-
Under your
Bitbucket Server
settings, locate theCall Can Merge
checkbox. -
This setting will need to be toggled on.
References
Reported Issue JENKINS-45997