Issue
Bitbucket Pull Requests fail with "ERROR: Could not do lightweight checkout, falling back to heavyweight"
ERROR: Could not do lightweight checkout, falling back to heavyweight java.io.FileNotFoundException: URL: /path/to/my/awesome/project/Jenkinsfile?at=pull-requests%2F59%2Fmerge&start=0&limit=500 at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getRequest(BitbucketServerAPIClient.java:834) at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getFileContent(BitbucketServerAPIClient.java:1129) at com.cloudbees.jenkins.plugins.bitbucket.filesystem.BitbucketSCMFile.content(BitbucketSCMFile.java:98) at jenkins.scm.api.SCMFile.contentAsString(SCMFile.java:335) at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:107) at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:309) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:428)
Environment
-
CloudBees CI (CloudBees Core) on modern cloud platforms - Managed controller
-
CloudBees CI (CloudBees Core) on traditional platforms - Client controller
-
CloudBees Jenkins Enterprise - Managed controller
-
Bitbucket Server >
7.0
-
Bitbucket Branch Source plugin <
2.9.0
Resolution
This is a known issue with BitBucket 7.0 that was reported in JIRA [JENKINS-61493] Lightweight checkout fails in Bitbucket Server 7.0; refs/pull-requests/*/merge does not exist - Jenkins JIRA
Here is the relevent comment from the JIRA
The linked comment below indicates that in BitBucket 7 Atlassian has removed the ability to do lightweight checkout while using the "Merging" strategy. This is "intentional" and "by-design" behavior implemented by Atlassian. It is beyond the control of Jenkins project to fix this at this time. If your build fails while attempting to checkout, be sure you’ve enabled "Call changes API" for your Bitbucket 7 endpoints.
The solution is to enable the Call changes API
for your BitBucket server endpoint. This setting can be enabled per BitBucket server endpoint under Jenkins > Manage Jenkins > Bitbucket Endpoints:
