Bitbucket Pull Requests fail with 'ERROR: Could not do lightweight checkout, falling back to heavyweight'

Article ID:360051726072
1 minute readKnowledge base

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)

Resolution

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:

bitbucket call changes api