Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-49353

Could not do lightweight checkout, falling back to heavyweight

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • None
    • Jenkins 2.104
      Jenkins Bitbucket Branch Source Plugin 2.2.9
      Bitbucket Server 5.6.0

      When building a PR that hasn't had changes to the Jenkinsfile within the PR, we see the following error at the beginning of each build:

      Branch event
      ERROR: Could not do lightweight checkout, falling back to heavyweight
      java.io.FileNotFoundException: URL: /rest/api/1.0/projects/TCD/repos/deployer-ish/browse/Jenkinsfile?at=PR-216&start=0&limit=500
      	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getRequest(BitbucketServerAPIClient.java:628)
      	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getFileContent(BitbucketServerAPIClient.java:867)
      	at com.cloudbees.jenkins.plugins.bitbucket.filesystem.BitbucketSCMFile.content(BitbucketSCMFile.java:99)
      	at jenkins.scm.api.SCMFile.contentAsString(SCMFile.java:338)
      	at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:104)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:271)
      	at hudson.model.ResourceController.execute(ResourceController.java:97)
      	at hudson.model.Executor.run(Executor.java:429)
      

      This is because Bitbucket Server does not expose the Jenkinsfile on such a PR, i.e.

      // 20180203112420
      // https://stash.my.com//rest/api/1.0/projects/TCD/repos/deployer-ish/browse/Jenkinsfile?at=PR-216&start=0&limit=500
      
      {
        "errors": [
          {
            "context": null,
            "message": "The path \"Jenkinsfile\" does not exist at revision \"PR-216\"",
            "exceptionName": "com.atlassian.bitbucket.content.NoSuchPathException"
          }
        ]
      }
      

      This should not be an error, as if there are no changes to the Jenkinsfile, then Bitbucket will not include the file on that request.

          [JENKINS-49353] Could not do lightweight checkout, falling back to heavyweight

          Robin Smith added a comment -

          I think the same issue also affects readTrusted. Since that function has no heavyweight checkout to fall back on, the errors seen here will cause a build failure when attempting a readTrusted operation during a Multbranch PR build with Bitbucket

          Robin Smith added a comment - I think the same issue also affects readTrusted . Since that function has no heavyweight checkout to fall back on, the errors seen here will cause a build failure when attempting a readTrusted operation during a Multbranch PR build with Bitbucket

          We are experiencing this same issue. This has increased our build time for pull requests, especially for some of our larger repositories.

          Jenkins: 2.89.4

          Bitbucket Branch Source Plugin: 2.2.10

          Bitbucket Server: 4.13.0

          We get the error in the description:

          /rest/api/1.0/projects/PROJNAME/repos/REPONAME/browse/Jenkinsfile?at=PR-106&start=0&limit=500

          But if I replace "PR-106" with another branch, like "development", the lightweight checkout works fine:

          /rest/api/1.0/projects/PROJNAME/repos/REPONAME/browse/Jenkinsfile?at=development&start=0&limit=500

           

          Thanks!

          Edward Basiliere added a comment - We are experiencing this same issue. This has increased our build time for pull requests, especially for some of our larger repositories. Jenkins: 2.89.4 Bitbucket Branch Source Plugin: 2.2.10 Bitbucket Server: 4.13.0 We get the error in the description: /rest/api/1.0/projects/PROJNAME/repos/REPONAME/browse/Jenkinsfile?at=PR-106&start=0&limit=500 But if I replace "PR-106" with another branch, like "development", the lightweight checkout works fine: /rest/api/1.0/projects/PROJNAME/repos/REPONAME/browse/Jenkinsfile?at=development&start=0&limit=500   Thanks!

          I seem to he facing exact same issue and I wonder if there is a way to fix it.

          Weird thing is that when using Multi branch pipeline job type (Bitbucket Team/Project) when job is triggered by a webhook it just won't work but then few minutes later you can run same job from UI and once you execute it manually without any changes it's pulling branch as normal.

          Wojtek Szpunar added a comment - I seem to he facing exact same issue and I wonder if there is a way to fix it. Weird thing is that when using Multi branch pipeline job type (Bitbucket Team/Project) when job is triggered by a webhook it just won't work but then few minutes later you can run same job from UI and once you execute it manually without any changes it's pulling branch as normal.

          I am also facing exactly the same issue and I really hope that there is a workaround available for this. A possible hot fix (before the actual issue gets fixed) can be: 

          • Provide an option in the Jenkins UI to explicitly go for a heavyweight checkout (when Bitbucket Source is chosen). Don't make a call to this API /rest/api/1.0/projects/PROJNAME/repos/REPONAME/browse/Jenkinsfile?at=PR-51&start=0&limit=500 every time a PR is submitted (i.e. when this option for heavyweight checkout is checked or when a option for lightweight checkout is unchecked). 

          Also, please solve this issue or as I mentioned above, please provide an option (a checkbox maybe in the Jenkins UI) to go for a heavyweight checkout. We don't need the lightweight checkout feature and we would be happy to go with a heavyweight checkout. 

          Thanks

          sharath mogadari added a comment - I am also facing exactly the same issue and I really hope that there is a workaround available for this. A possible hot fix (before the actual issue gets fixed) can be:  Provide an option in the Jenkins UI to explicitly go for a heavyweight checkout (when Bitbucket Source is chosen). Don't make a call to this API /rest/api/1.0/projects/PROJNAME/repos/REPONAME/browse/Jenkinsfile?at=PR-51&start=0&limit=500 every time a PR is submitted (i.e. when this option for heavyweight checkout is checked or when a option for lightweight checkout is unchecked).  Also, please solve this issue or as I mentioned above, please provide an option (a checkbox maybe in the Jenkins UI) to go for a heavyweight checkout . We don't need the lightweight checkout feature and we would be happy to go with a heavyweight checkout.  Thanks

          Matthias F added a comment -

          Same here, the URL uses a wrong parameter (PR-XXX) instead of the branch name. I couldn't find any parameter that would me allow to change that.

          Matthias F added a comment - Same here, the URL uses a wrong parameter (PR-XXX) instead of the branch name. I couldn't find any parameter that would me allow to change that.

          When I create a pull request in Bitbucket my build fails, see attached image for details. 

          Couldn't find remote ref refs/pull-requests/42/from
          • Another thing I have noticed is that when I go to Jenkins UI and re-trigger the build it builds without any errors.
          • Next if I commit to my branch/PR build runs without errors
          • Next when I decline the PR and then open the same PR it again fails and this time when I try to re trigger build from Jenkins UI it continues to fail with the same error and I end up with having to
            • create a new PR with the only solution to run my build pipeline, OR
            • I do a new commit  and that triggers a successful build

          My environments are: 

          • Jenkins ver. 2.197
          • Bitbucket Branch Source plugin 2.4.6
          • JENKINS-59808

          tanzeel rehman added a comment - When I create a pull request in Bitbucket my build fails, see attached image for details.  Couldn't find remote ref refs/pull-requests/42/from Another thing I have noticed is that when I go to Jenkins UI and re-trigger the build it builds without any errors. Next if I commit to my branch/PR build runs without errors Next when I decline the PR and then open the same PR it again fails and this time when I try to re trigger build from Jenkins UI it continues to fail with the same error and I end up with having to create a new PR with the only solution to run my build pipeline, OR I do a new commit  and that triggers a successful build My environments are:  Jenkins ver. 2.197 Bitbucket Branch Source plugin 2.4.6 JENKINS-59808

          Liam Newman added a comment - - edited

          It is likely that the ref is being cleaned up by BitBucket.  As shown by https://issues.jenkins-ci.org/browse/JENKINS-61493 , Atlassian treated the merge ref as an implementation detail that should not be depended on.  

          See that issue for workaround.

          Liam Newman added a comment - - edited It is likely that the ref is being cleaned up by BitBucket.  As shown by https://issues.jenkins-ci.org/browse/JENKINS-61493  , Atlassian treated the merge ref as an implementation detail that should not be depended on.   See that issue for workaround.

          Liam Newman added a comment -

          I believe this issue was fixed by https://github.com/jenkinsci/bitbucket-branch-source-plugin/pull/409 and released in v2.9.6. Could someone please try this and verify whether this is so?

          Liam Newman added a comment - I believe this issue was fixed by https://github.com/jenkinsci/bitbucket-branch-source-plugin/pull/409 and released in v2.9.6. Could someone please try this and verify whether this is so?

          Nikolas Falco added a comment -

          Is this issue still present in latest plugin version?
          Do you read the user documentation at https://github.com/jenkinsci/bitbucket-branch-source-plugin/blob/master/docs/USER_GUIDE.adoc ? Focus on the first chapter

          Nikolas Falco added a comment - Is this issue still present in latest plugin version? Do you read the user documentation at https://github.com/jenkinsci/bitbucket-branch-source-plugin/blob/master/docs/USER_GUIDE.adoc ? Focus on the first chapter

          Nikolas Falco added a comment - - edited

          This issue seems the same of JENKINS-49740 where the problem was in the API URL.
          This issue should be already be fixed. Please let me know and in case reopen the issue

          Nikolas Falco added a comment - - edited This issue seems the same of JENKINS-49740 where the problem was in the API URL. This issue should be already be fixed. Please let me know and in case reopen the issue

            nfalco Nikolas Falco
            bengineer Ben Middleton
            Votes:
            24 Vote for this issue
            Watchers:
            32 Start watching this issue

              Created:
              Updated:
              Resolved: