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

Lightweight checkout fails when Pipeline JenkinsFile is in a subfolder

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • Jenkins 2.73.2
      Bitbucket Branch Source Plugin 2.2.7

      The following error appears in a build output: 

      ERROR: Could not do lightweight checkout, falling back to heavyweight
      java.io.FileNotFoundException: URL: /rest/api/1.0/projects/PROJNAME/repos/reponame/browse/devopsJenkinsfile-CI/?at=master&start=0&limit=500
      	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getRequest(BitbucketServerAPIClient.java:517)
      	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getFileContent(BitbucketServerAPIClient.java:723)
      	at com.cloudbees.jenkins.plugins.bitbucket.filesystem.BitbucketSCMFile.content(BitbucketSCMFile.java:81)
      

      We have the JenkinsFile within a subdirectory of the repo, not the root directory, and the job is configured the same with the Pipeline Jenkinsfile as follows:

      devops/Jenkinsfile-CI
      

      When pasting the path into a browser, it returns:

      {"errors":[{"context":null,"message":"The path \"devopsJenkinsfile-CI/\" does not exist at revision \"master\"","exceptionName":"com.atlassian.bitbucket.content.NoSuchPathException"}]}
      

      If we move the forward slash to the correct place in the URL

      /rest/api/1.0/projects/PROJNAME/repos/reponame/browse/devops/Jenkinsfile-CI?at=master&start=0&limit=500

      Then Bitbucket server returns the contents on the file in JSON.

          [JENKINS-48504] Lightweight checkout fails when Pipeline JenkinsFile is in a subfolder

          Trask added a comment -

          We've got the exact same issue.  Jenkins 2.94.  BB branch source plugin 2.2.7

          Trask added a comment - We've got the exact same issue.  Jenkins 2.94.  BB branch source plugin 2.2.7

          Nenad Miksa added a comment -

          Also happens to me as well. It didn't happen in 2.2.3.

          Nenad Miksa added a comment - Also happens to me as well. It didn't happen in 2.2.3.

          Scott Russell added a comment - - edited

          Reporting the same or similar issue seen on Jenkins 2.89.2, Bitbucket Branch Source 2.2.8, where our branch name is "dev/odata" in Bitbucket:

           

           

          ERROR: Could not do lightweight checkout, falling back to heavyweight java.io.FileNotFoundException: URL:
          https://api.bitbucket.org/2.0/repositories/TEAM_NAME/REPO_NAME/src/dev%2Fodata/Jenkinsfile
          at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRequestAsInputStream(BitbucketCloudApiClient.java:576) at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getFileContent(BitbucketCloudApiClient.java:743) at com.cloudbees.jenkins.plugins.bitbucket.filesystem.BitbucketSCMFile.content(BitbucketSCMFile.java:81) 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:247) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:421)
          

           

          Scott Russell added a comment - - edited Reporting the same or similar issue seen on Jenkins 2.89.2, Bitbucket Branch Source 2.2.8, where our branch name is "dev/odata" in Bitbucket:     ERROR: Could not do lightweight checkout, falling back to heavyweight java.io.FileNotFoundException: URL: https: //api.bitbucket.org/2.0/repositories/TEAM_NAME/REPO_NAME/src/dev%2Fodata/Jenkinsfile at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRequestAsInputStream(BitbucketCloudApiClient.java:576) at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getFileContent(BitbucketCloudApiClient.java:743) at com.cloudbees.jenkins.plugins.bitbucket.filesystem.BitbucketSCMFile.content(BitbucketSCMFile.java:81) 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:247) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:421)  

          Robin Smith added a comment -

          robertd now PR #111 is merged and JENKINS-49671 resolved, I think this issue should be fixed. Can you confirm? Fix is in 2.2.11 release of the plugin

          Robin Smith added a comment - robertd now PR #111 is merged and JENKINS-49671 resolved, I think this issue should be fixed. Can you confirm? Fix is in 2.2.11 release of the plugin

          Robert D added a comment -

          robin_smith, I no longer see the lightweight checkout error with plugin version 2.2.11 (on Jenkins 2.107).

          The build's console output shows "Obtained subdir/Jenkinsfile from <git-commit-hash>", unsure if that is from BBSP or another plugin.

          Since we're no longer getting the lightweight error with the FileNotFoundException, and our atlassian-bitbucket.log is showing the correct "GET .../subdir/Jenkinsfile" request format, I can confirm this is fixed for us.

          Robert D added a comment - robin_smith , I no longer see the lightweight checkout error with plugin version 2.2.11 (on Jenkins 2.107). The build's console output shows "Obtained subdir/Jenkinsfile from <git-commit-hash>", unsure if that is from BBSP or another plugin. Since we're no longer getting the lightweight error with the FileNotFoundException, and our atlassian-bitbucket.log is showing the correct "GET .../subdir/Jenkinsfile" request format, I can confirm this is fixed for us.

          Robin Smith added a comment -

          Fixed by PR #111 in version 2.2.11 of the plugin (see JENKINS-49671)

          Robin Smith added a comment - Fixed by PR #111 in version 2.2.11 of the plugin (see JENKINS-49671 )

            Unassigned Unassigned
            robertd Robert D
            Votes:
            9 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: