bitbucket-branch-source-plugin: Pull-Requests no longer working on BitBucket Server 7.0
Your checklist for this issue
-
Jenkins version: 2.204.5
-
Plugin version: 2.7.0
-
Bitbucket cloud
-
Bitbucket server and version: 7.0.0, 7.0.1
Description
This plugin is no longer able to fetch and build pull-requests. Looks like thay changed the api without writing a note.
06:01:26 Started by user XXX YYY
06:01:26 Running as XXX YYY
06:01:34 ERROR: Could not do lightweight checkout, falling back to heavyweight
06:01:34 java.io.FileNotFoundException: URL: /rest/api/1.0/projects/proj/repos/repo/browse/Jenkinsfile?at=pull-requests%2F580%2Fmerge&start=0&limit=500
06:01:34 at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getRequest(BitbucketServerAPIClient.java:831)
06:01:34 at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getFileContent(BitbucketServerAPIClient.java:1123)
06:01:34 at com.cloudbees.jenkins.plugins.bitbucket.filesystem.BitbucketSCMFile.content(BitbucketSCMFile.java:98)
06:01:34 at jenkins.scm.api.SCMFile.contentAsString(SCMFile.java:335)
06:01:34 at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:107)
06:01:34 at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:299)
06:01:34 at hudson.model.ResourceController.execute(ResourceController.java:97)
06:01:34 at hudson.model.Executor.run(Executor.java:427)
06:01:34 Checking out git https://xxx.yyyy.de/scm/proj/repo.git https://xxx.yyyy.de/scm/proj/repo.git into /var/jenkins_home/workspace/proj_repo_PR-580@script to read Jenkinsfile
06:01:34 using credential a63b7cb8-6690-4c0b-81b8-93969a0fabac
06:01:35 using credential a63b7cb8-6690-4c0b-81b8-93969a0fabac
06:01:35 > git rev-parse --is-inside-work-tree # timeout=10
06:01:35 Fetching changes from 2 remote Git repositories
06:01:35 > git config remote.origin.url https://xxx.yyyy.de/scm/proj/repo.git # timeout=10
06:01:35 Cleaning workspace
06:01:35 > git rev-parse --verify HEAD # timeout=10
06:01:35 No valid HEAD. Skipping the resetting
06:01:35 > git clean -ffdx # timeout=10
06:01:35 Pruning obsolete local branches
06:01:35 Fetching upstream changes from https://xxx.yyyy.de/scm/proj/repo.git
06:01:35 > git --version # timeout=10
06:01:35 using GIT_ASKPASS to set credentials
06:01:35 > git fetch --tags --force --progress --prune -- https://xxx.yyyy.de/scm/proj/repo.git +refs/pull-requests/580/from:refs/remotes/origin/PR-580 # timeout=10
06:01:35 ERROR: Error fetching remote repo 'origin'
06:01:35 hudson.plugins.git.GitException: Failed to fetch from https://xxx.yyyy.de/scm/proj/repo.git
06:01:35 at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:909)
06:01:35 at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1131)
06:01:35 at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1167)
06:01:35 at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:124)
06:01:35 at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:155)
06:01:35 at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:142)
06:01:35 at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:299)
06:01:35 at hudson.model.ResourceController.execute(ResourceController.java:97)
06:01:35 at hudson.model.Executor.run(Executor.java:427)
06:01:35 Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --force --progress --prune -- https://xxx.yyyy.de/scm/proj/repo.git +refs/pull-requests/580/from:refs/remotes/origin/PR-580" returned status code 128:
06:01:35 stdout:
06:01:35 stderr: fatal: Couldn't find remote ref refs/pull-requests/580/from
06:01:35
06:01:35 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2430)
06:01:35 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2044)
06:01:35 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:81)
06:01:35 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:569)
06:01:35 at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:907)
06:01:35 ... 8 more
06:01:35 ERROR: Error fetching remote repo 'origin'
06:01:35 [Bitbucket] Notifying pull request build result
06:01:36 [Bitbucket] Build result notified
06:01:36 ERROR: Maximum checkout retry attempts reached, aborting
06:01:36 Finished: FAILURE
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 5
- Comments: 101 (49 by maintainers)
lightweight checkout is no longer possible with bitbucket server v7 and merge build strategy, because bitbucket no longer computes a merge commit.
@joaoportela actually that makes perfect sense if you didn’t push any new changes in between. The “Call changes API” only needs to be called once to ensure the refs are created on Bitbucket. This is also what happens if you view the diff in the Bitbucket UI. Once the refs are created the plugin can do its thing (with the heavyweight checkout). What the “Call changes API” does is ensure that Bitbucket for sure created the refs (because with Bitbucket 7 they are only created on demand).
We’re having the same issue. The PR #294 seems to fix it.
We got the build 2.8.1-rc648.98e3c549af77 from jenkins-ci repo.
We enabled the “Call Changes API” option at https://SERVERADDRESS/configure like you guys said.
Unfortunately, it still falls back to heavyweight checkout but at least the heavyweight checkout is working. 😄
as a workaround i disable pr’s and only build regular branches
regarding LFS checkout, I toyed with the idea of either an extension plugin or a contribution to the git plugin to add a scm filter for ignoring LFS checkout on master. Never got anywhere but should be simple to write a filter.
The issue of heavy checkout has not been resolved.
One simple solution is to add this environment variable on Jenkins master:
GIT_LFS_SKIP_SMUDGE=1
Or run this command to ignore LFS checkout:git config --global filter.lfs.smudge "git-lfs smudge --skip"
There’s a discussion on this a few posts up from myself. Those options are in the settings for the plugin in Jenkins i.e. where you configure the address etc. for your Bitbucket server. They’re not on by default because the developer doesn’t want to assume that everyone is using the latest version of Bitbucket, if you’re running an older version those options will cause the plugin to fail. I believe I made the suggestion that the plugin could query the Bitbucket REST API to find out what version of Bitbucket was being used and then apply the correct setting accordingly. I’m not a Java Dev so I don’t really know how hard that is to actually implement.
On Fri, 12 Jun 2020, 01:18 Mike Sollanych, notifications@github.com wrote:
For those who installed RC version and still see the problem - make sure you install the correct one https://repo.jenkins-ci.org/incrementals/org/jenkins-ci/plugins/cloudbees-bitbucket-branch-source/2.7.1-rc629.f242e60a14b4/ We installed the newer RC version today and still see the problem. Installing exactly this one solved it for us - building pull requests on Jenkins work back again for us.
Hi again, can confirm that the following RC build: https://repo.jenkins-ci.org/incrementals/org/jenkins-ci/plugins/cloudbees-bitbucket-branch-source/2.7.1-rc629.f242e60a14b4/ (link copied from above) solves the problem for us. We still see the “Lightweight error” at the beginning of the run, however it then continues without issue.
Have we considered forcing the refs creation again by different call to API? Bad approach, but a quick-fix? (as discussed in https://issues.jenkins-ci.org/browse/JENKINS-61493)