Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull-Requests no longer working on BitBucket Server 7.0 #287

Closed
3 of 4 tasks
viceice opened this issue Mar 9, 2020 · 101 comments · Fixed by #294
Closed
3 of 4 tasks

Pull-Requests no longer working on BitBucket Server 7.0 #287

viceice opened this issue Mar 9, 2020 · 101 comments · Fixed by #294

Comments

@viceice
Copy link
Member

viceice commented Mar 9, 2020

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

https://community.atlassian.com/t5/Bitbucket-questions/Bitbucket-Server-7-0-PR-fetch-from-not-working/qaq-p/1320053

@jetersen
Copy link
Member

jetersen commented Mar 9, 2020

🤷‍♂ Feel free to revert until some kind soul contributes the code for Bitbucket 7

@viceice
Copy link
Member Author

viceice commented Mar 9, 2020

Ok, trying to build a fix.

@jetersen
Copy link
Member

jetersen commented Mar 9, 2020

Not seeing anything note worthy: https://developer.atlassian.com/server/bitbucket/reference/api-changelog/ so double 🤷‍♂

@viceice
Copy link
Member Author

viceice commented Mar 9, 2020

as a workaround i disable pr's and only build regular branches

@jetersen
Copy link
Member

jetersen commented Mar 9, 2020

Hmm sure your it is not a one time thing: https://docs.atlassian.com/bitbucket-server/rest/7.0.1/bitbucket-rest.html#idp280 this is still documented as is.

@viceice
Copy link
Member Author

viceice commented Mar 9, 2020

ok, updating to 7.01 to see if its a bitbucket bug

@jetersen
Copy link
Member

jetersen commented Mar 9, 2020

@jetersen
Copy link
Member

jetersen commented Mar 9, 2020

The at field looks funky though 😓

@viceice
Copy link
Member Author

viceice commented Mar 9, 2020

yes, i think there should be the commit id.

@jetersen
Copy link
Member

jetersen commented Mar 9, 2020

You'd have to debug what the API is returning since that is somewhat unexpected 🤔

@viceice
Copy link
Member Author

viceice commented Mar 9, 2020

ok, np. i have some java experience. i also know the bitbucket api from our renovatebot 😅

@viceice
Copy link
Member Author

viceice commented Mar 9, 2020

Looks like 7.0.1 is working 🤔

@jetersen
Copy link
Member

jetersen commented Mar 9, 2020

😖

@viceice
Copy link
Member Author

viceice commented Mar 9, 2020

so closing this as it's working again. 🤷‍♂️

@viceice viceice closed this as completed Mar 9, 2020
@viceice viceice reopened this Mar 9, 2020
@viceice
Copy link
Member Author

viceice commented Mar 9, 2020

There is something wrong.

git fetch +refs/pull-requests/575/from:refs/remotes/origin/PR-575

image

They should be equal. pr is opened from renovate/jint-3.0.x to master

@wwuck
Copy link

wwuck commented Mar 10, 2020

I'm also seeing this same issue with building PRs after upgrading to Bitbucket 7.0.1 yesterday. Anything I can do/test to help get this fixed?

@viceice
Copy link
Member Author

viceice commented Mar 11, 2020

Nope, disabled pr build for now. Currently the only fix is to downgrade.

@viceice viceice changed the title Pull-Requests no longer working on BitBucket Server 7.0.0 Pull-Requests no longer working on BitBucket Server 7.0 Mar 11, 2020
@viceice
Copy link
Member Author

viceice commented Mar 11, 2020

stderr: fatal: Couldn't find remote ref refs/pull-requests/580/from is gone with 7.0.1, but refs/pull-requests/580/from is no longer updated by bitbucket after pushing new commits.

@jftsunami
Copy link

jftsunami commented Mar 16, 2020

The git refrences pull request refs (refs/pull-requests/*) have never been supported by BitBucket / Atlassian as part of their API. https://community.atlassian.com/t5/Bitbucket-questions/Difference-of-refs-pull-requests-lt-ID-gt-merge-and-refs-pull/qaq-p/772142

@viceice
Copy link
Member Author

viceice commented Mar 17, 2020

OK, trying to send a pr which uses the rest api

@viceice
Copy link
Member Author

viceice commented Mar 17, 2020

Are I'm right that this need to be fixed here:

if (head instanceof PullRequestSCMHead) {
if (scmSource.buildBitbucketClient() instanceof BitbucketCloudApiClient) {
// TODO fix once Bitbucket Cloud has a fix for https://bitbucket.org/site/master/issues/5814
String branchName = ((PullRequestSCMHead) head).getBranchName();
withRefSpec("+refs/heads/" + branchName + ":refs/remotes/@{remote}/" + head.getName());
} else {
String pullId = ((PullRequestSCMHead) head).getId();
withRefSpec("+refs/pull-requests/" + pullId + "/from:refs/remotes/@{remote}/" + head.getName());
}
} else if (head instanceof TagSCMHead ){

@alexey-pelykh
Copy link
Contributor

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)

@dcherniv
Copy link

dcherniv commented Apr 6, 2020

I tried the latest RC
https://repo.jenkins-ci.org/incrementals/org/jenkins-ci/plugins/cloudbees-bitbucket-branch-source/2.7.1-rc629.f242e60a14b4/
Doesn't appear to work properly. We have git-lfs on one of our repos and heavyweight checkout appears to be broken with git lfs.
git lfs binary is installed on the jenkins master.

12:54:24  ERROR: Could not do lightweight checkout, falling back to heavyweight
12:54:24  java.io.FileNotFoundException: URL: /rest/api/1.0/projects/ML/repos/repo/browse/Jenkinsfile?at=pull-requests%2F219%2Fmerge&start=0&limit=500
12:54:24  	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getRequest(BitbucketServerAPIClient.java:831)
12:54:24  	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getFileContent(BitbucketServerAPIClient.java:1123)
12:54:24  	at com.cloudbees.jenkins.plugins.bitbucket.filesystem.BitbucketSCMFile.content(BitbucketSCMFile.java:98)
12:54:24  	at jenkins.scm.api.SCMFile.contentAsString(SCMFile.java:335)
12:54:24  	at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:107)
12:54:24  	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:309)
12:54:24  	at hudson.model.ResourceController.execute(ResourceController.java:97)
12:54:24  	at hudson.model.Executor.run(Executor.java:428)
12:54:24  Checking out git https://bb.example.com/scm/ML/repo.git https://bb.example.com/scm/ML/repo.git into /var/jenkins_home/workspace/repo_PR-219@script to read Jenkinsfile
12:54:24  using credential jenkins
12:54:24  using credential jenkins

Which then later times out with:

12:54:40  Merging remotes/upstream/master commit a9bc1aac607fa24a97711736a18bfda3c651d1f1 into PR head commit 75dc89073f8627ecd7434f614138e726016d00a0
12:54:40   > git config core.sparsecheckout # timeout=10
12:54:40   > git checkout -f 75dc89073f8627ecd7434f614138e726016d00a0 # timeout=10
12:59:08  ERROR: Checkout failed
12:59:08  java.lang.InterruptedException
12:59:08  	at java.lang.Object.wait(Native Method)
12:59:08  	at java.lang.Object.wait(Object.java:502)
12:59:08  	at java.lang.UNIXProcess.waitFor(UNIXProcess.java:395)
12:59:08  	at hudson.Proc$LocalProc.join(Proc.java:327)
12:59:08  	at hudson.Proc.joinWithTimeout(Proc.java:172)
12:59:08  	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2423)
12:59:08  	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$1100(CliGitAPIImpl.java:81)
12:59:08  	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:2743)
12:59:08  	at jenkins.plugins.git.MergeWithGitSCMExtension.checkout(MergeWithGitSCMExtension.java:144)
12:59:08  	at jenkins.plugins.git.MergeWithGitSCMExtension.decorateRevisionToBuild(MergeWithGitSCMExtension.java:110)
12:59:08  	at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:1063)
12:59:08  	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1168)
12:59:08  	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:124)
12:59:08  	at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:155)
12:59:08  	at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:142)
12:59:08  	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:309)
12:59:08  	at hudson.model.ResourceController.execute(ResourceController.java:97)
12:59:08  	at hudson.model.Executor.run(Executor.java:428)
12:59:08  [Bitbucket] Notifying pull request build result
12:59:08  [Bitbucket] Build result notified
12:59:08  ERROR: Maximum checkout retry attempts reached, aborting
12:59:08  Finished: FAILURE

@spacehorst
Copy link

I can confirm this issue using Plugin Version 2.7.0 with Bitbucket Server 7.1.0

@mlasevich
Copy link
Contributor

+1 on issue with BB 7.1.0 - our guys upgraded BB this weekend and all PRs no longer build (and we lean heavily on them) - is there a patch yet?

@jetersen
Copy link
Member

Both #294 and #302 is a workable solution.

Although #302 needs some refinements as it is basically a hack abusing the can merge api call. While it would be great to support both can merge and poking the PR changes api.

@joaoportela
Copy link

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.
image

Unfortunately, it still falls back to heavyweight checkout but at least the heavyweight checkout is working. 😄

@viceice
Copy link
Member Author

viceice commented May 8, 2020

lightweight checkout is no longer possible with bitbucket server v7 and merge build strategy, because bitbucket no longer computes a merge commit.

@joaoportela
Copy link

joaoportela commented May 8, 2020

Just another update from my side.

Looking at the build logs and comparing it with PR #294 changes it didn't seem to be using the "Call changes API" code path.

So I unchecked that option and ran the builds again and it still works... 🤷‍♂️

I guess the issue for me was something else that hasn't made it into stable release yet.

More details if you guys need it:

  • Jenkins version 2.222.3
  • Bitbucket version 7.1.1

@mattiassluis
Copy link
Contributor

@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).

@mattiassluis
Copy link
Contributor

With regards to my earlier comment: #287 (comment) This seems to be some mistake with the webhooks on our end. The latest releases have worked good for us (but since we need to roll this out to many Jenkins servers we are hoping on an official release soon)

@tomk3003
Copy link

I just tested with 2.8.1-rc648.98e3c549af77 with "Call Changes api" activated and "Can Call Merge" deactivated against Bitbucket Server 7.1.2 and can confirm that PRs from within a repo as well as PRs from forks are triggered successfully.. The only thing that is still missing, is triggering a build when a PR gets pushed into. But I think for that, handling of the new webhook "Source branch updated" (#308) is needed.

@JeroennC
Copy link

JeroennC commented May 14, 2020

Another github user @Cyanoth (thanks!) created an alternative solution to this issue, creating a bitbucket plugin that executes the diff call whenever a PR is created / updated: https://github.com/Cyanoth/Bitbucket-EagerPR-Updates

We've just installed this to our bitbucket server, and it works well. I'm not sure if it guarantees the refs/pull-requests/<x>/from ref is updated before the Jenkins job is triggered though.

I also like how this solution works regardless of the CI used. Would be best if this plugin still gets #294 though IMO

@spacehorst
Copy link

I confirm tomk3030. 2.8.1-rc648.98e3c549af77 works with Bitbucket Server 7.1.0 setting "Call Changes API" true and "Can Call Merge" false. Even a subsequent push to the source branch triggered a rebuild of the PR.

@mike-sol
Copy link

mike-sol commented Jun 10, 2020

Still seeing this issue on the first build of a multibranch pipeline with 2.8.1-rc648.98e3c549af77 installed. Subsequent, manually triggered builds seem to work.

Running against Bitbucket Server 7.3.0 and happy to try out new builds of the plugin on Jenkins.

ERROR: Could not do lightweight checkout, falling back to heavyweight
java.io.FileNotFoundException: URL: /rest/api/1.0/projects/REPONAME/repos/REPONAME/browse/rpm/pipelines/pull-request/Jenkinsfile?at=pull-requests%2F2636%2Fmerge&start=0&limit=500
	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getRequest(BitbucketServerAPIClient.java:855)
	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getFileContent(BitbucketServerAPIClient.java:1150)
	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)
Checking out git https://git.REDACTED.local/scm/REPONAME/REPONAME.git https://git.REDACTED.local/scm/REPONAME/REPONAME.git into /var/lib/jenkins/workspace/SSW_REPONAME-pr-build_PR-2636@script to read rpm/pipelines/pull-request/Jenkinsfile
using credential CREDENTIAL-NAME
using credential CREDENTIAL-NAME
Cloning the remote Git repository
Cloning with configured refspecs honoured and without tags
Cloning repository https://git.REDACTED.local/scm/REPONAME/REPONAME.git
 > git init /var/lib/jenkins/workspace/SSW_REPONAME-pr-build_PR-2636@script # timeout=10
Fetching upstream changes from https://git.REDACTED.local/scm/REPONAME/REPONAME.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials Read-only personal access token for stash.jenkins BitBucket user
 > git fetch --no-tags --force --progress -- https://git.REDACTED.local/scm/REPONAME/REPONAME.git +refs/pull-requests/2636/from:refs/remotes/origin/PR-2636 # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --no-tags --force --progress -- https://git.REDACTED.local/scm/REPONAME/REPONAME.git +refs/pull-requests/2636/from:refs/remotes/origin/PR-2636" returned status code 128:
stdout: 
stderr: fatal: couldn't find remote ref refs/pull-requests/2636/from

	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2430)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2044)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:81)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:569)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:798)
	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1122)
	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1167)
	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:125)
	at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:155)
	at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:142)
	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)
ERROR: Error cloning remote repo 'origin'
[Bitbucket] Notifying pull request build result
[Bitbucket] Build result notified
ERROR: Maximum checkout retry attempts reached, aborting
Finished: FAILURE

@spacehorst
Copy link

The first build for a new PR is also automatically triggered and successfully built on the before mentioned configuration of our systems.

@mike-sol
Copy link

@spacehorst You mention "Bitbucket Server 7.1.0 setting "Call Changes API" true and "Can Call Merge" false" - where does one configure those? Were they non-default settings?

@muppet3000
Copy link

muppet3000 commented Jun 12, 2020 via email

@mike-sol
Copy link

Thanks @muppet3000, I have enabled that option and will report back when my devs have tested things out.

@mike-sol
Copy link

Looks like we're good over here. Here's the top of the build output from a now-working PR.

It would be nice if it didn't throw the exception, and instead have some way to detect this case and not litter build output with unnecessary errors.

ERROR: Could not do lightweight checkout, falling back to heavyweight
java.io.FileNotFoundException: URL: /rest/api/1.0/projects/REPO/repos/REPO/browse/rpm/pipelines/pull-request/Jenkinsfile?at=pull-requests%2F2647%2Fmerge&start=0&limit=500
	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getRequest(BitbucketServerAPIClient.java:855)
	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getFileContent(BitbucketServerAPIClient.java:1150)
	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)
Checking out git https://git.COMPANY.local/scm/REPO/REPO.git https://git.COMPANY.local/scm/REPO/REPO.git into /var/lib/jenkins/workspace/SSW_REPO-pr-build_PR-2647@script to read rpm/pipelines/pull-request/Jenkinsfile
using credential CRED
using credential CRED
Cloning the remote Git repository
Cloning with configured refspecs honoured and without tags
Cloning repository https://git.COMPANY.local/scm/REPO/REPO.git
 > git init /var/lib/jenkins/workspace/SSW_REPO-pr-build_PR-2647@script # timeout=10
Fetching upstream changes from https://git.COMPANY.local/scm/REPO/REPO.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials Read-only personal access token for stash.jenkins BitBucket user
 > git fetch --no-tags --force --progress -- https://git.COMPANY.local/scm/REPO/REPO.git +refs/pull-requests/2647/from:refs/remotes/origin/PR-2647 # timeout=10
 > git config remote.origin.url https://git.COMPANY.local/scm/REPO/REPO.git # timeout=10
 > git config --add remote.origin.fetch +refs/pull-requests/2647/from:refs/remotes/origin/PR-2647 # timeout=10
 > git config remote.origin.url https://git.COMPANY.local/scm/REPO/REPO.git # timeout=10
Fetching without tags
Fetching upstream changes from https://git.COMPANY.local/scm/REPO/REPO.git
using GIT_ASKPASS to set credentials Read-only personal access token for stash.jenkins BitBucket user
 > git fetch --no-tags --force --progress -- https://git.COMPANY.local/scm/REPO/REPO.git +refs/pull-requests/2647/from:refs/remotes/origin/PR-2647 # timeout=10
 > git config remote.upstream.url https://git.COMPANY.local/scm/REPO/REPO.git # timeout=10
Fetching without tags
Fetching upstream changes from https://git.COMPANY.local/scm/REPO/REPO.git
using GIT_ASKPASS to set credentials Read-only personal access token for stash.jenkins BitBucket user
 > git fetch --no-tags --force --progress -- https://git.COMPANY.local/scm/REPO/REPO.git +refs/heads/master:refs/remotes/upstream/master # timeout=10
Merging remotes/upstream/master commit 96ca0c51ba0d19112daf521fa3e97c2603f7345e into PR head commit fc69bfd35092dd27d31e7c1d1e7774296038c625
 > git config core.sparsecheckout # timeout=10
 > git checkout -f fc69bfd35092dd27d31e7c1d1e7774296038c625 # timeout=10
 > git remote # timeout=10
 > git config --get remote.origin.url # timeout=10
using GIT_ASKPASS to set credentials Read-only personal access token for stash.jenkins BitBucket user
 > git merge 96ca0c51ba0d19112daf521fa3e97c2603f7345e # timeout=10
 > git rev-parse HEAD^{commit} # timeout=10
Merge succeeded, producing fc69bfd35092dd27d31e7c1d1e7774296038c625
Checking out Revision fc69bfd35092dd27d31e7c1d1e7774296038c625 (PR-2647)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f fc69bfd35092dd27d31e7c1d1e7774296038c625 # timeout=10
Commit message: "Revert "Reverting changes to demo.py""
First time build. Skipping changelog.
[Bitbucket] Notifying pull request build result
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline (show)
[Bitbucket] Notifying pull request build result
[Bitbucket] Build result notified
Finished: SUCCESS

@jglick
Copy link
Member

jglick commented Jun 16, 2020

It would be nice if it didn't throw the exception, and instead have some way to detect this case and not litter build output with unnecessary errors.

That would have to be in

Be sure to test not just an empty Jenkinsfile but one including

node {
  checkout scm
}

@muppet3000
Copy link

muppet3000 commented Jun 29, 2020

I've just had a new issue brought to my attention on this and I don't know if it's as a result of the changes to the plugin or something else. Would be grateful if others could confirm.
We have our Jenkins configured in "Exclude branches that are also filed as PRs", however, quite often someone will make some changes to a feature and push them, then immediately create a PR.
This results in a running "feature" branch job, and then another running "PR" job following shortly behind. In bitbucket however, this shows as just a single running job - whatever one was triggered last (in this case the PR), but I'm 100% certain that it used to show as 2 jobs - one for the feature branch and another for the PR branch.

What happens is that the feature job finishes whilst the PR is still running and then updates the job status on the Bitbucket PR/commit to show that the feature branch has passed. This allows a PR to then be merged whilst a job (the PR job) is still running, breaking the whole point of having a PR build (All of our pipelines are configured to do more extensive tests when it's a PR, therefore if a feature branch sneaks in and sets the status to green while there are tests that still haven't been run code can get merged in with failures in it - without anyone realising). When the PR then finishes (slightly later) it then updates the job again with the status of it's build (to the one we actually care about).

Has anyone else seen this behaviour? I'll do more investigation tomorrow to determine whether or not this is related to this plugin, or another plugin. I'll attempt to roll back the plugin we have installed on one of our instances to a "pre dev" build of this one and see if the behaviour persists or goes away, if it goes away then the issue is in this "fix".

Can anyone else out there confirm whether they're seeing the same issue with this dev build of the plugin? We've just upgraded all of our Jenkins instances to the latest LTS and latest plugins, so there have been lots of changes that I need to rule out.

@viceice
Copy link
Member Author

viceice commented Jun 29, 2020

@muppet3000 I've seen this too, this has nothing todo with this issue. So please file a new issue for that

@muppet3000
Copy link

muppet3000 commented Jun 29, 2020 via email

@viceice
Copy link
Member Author

viceice commented Jun 29, 2020

@muppet3000 sorry, I've seen it before I switch to the dev build. I have some jobs which requires 15 and more minutes to succeed, so if I push a branch and open a PR shortly after it, I can see your behavior on all releases since ~1 year

@muppet3000
Copy link

muppet3000 commented Jun 29, 2020 via email

@muppet3000
Copy link

@viceice I've just created this new issue to address the separate problem we discussed yesterday: #324
Would appreciate your +1/backing/comments on it to help bump it up the priority.

@mlasevich
Copy link
Contributor

Just run into an issue with falling back to heavyweight checkout. When faced with a repo that has LSF enabled, it tries to do LFS, which is not available on master. My two questions are - have the issue of falling back to heavyweight been resolved here and if not, is there a way to disable LFS during heavyweight checkout for purposes of this plugin while still having it enabled for actual checkout on the remote nodes?

@jetersen
Copy link
Member

jetersen commented Jul 8, 2020

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"

@jetersen
Copy link
Member

jetersen commented Jul 8, 2020

Added workarounds for LFS checkout on master in the above message so to write plugin might seem overkill.

@mlasevich
Copy link
Contributor

Thanks. For now I removed the LFS from my job config and added it manually in checkout step in Jenkinsfile(hurray for global libs) - but it would be much cleaner using the env variable being that master does not even have LFS installed, so it will not work in any case.

@jetersen
Copy link
Member

jetersen commented Jul 8, 2020

Ya that's where the plugin would be useful when LFS is not installed on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.