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

readTrusted fails on Bitbucket PR branch

XMLWordPrintable

      readTrusted fails when building Bitbucket PRs, with the following error:

      java.io.FileNotFoundException: URL: /rest/api/1.0/projects/xx/repos/yy/browse/pr.groovy?at=PR-86&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.ReadTrustedStep$Execution.run(ReadTrustedStep.java:179)
      	at org.jenkinsci.plugins.workflow.multibranch.ReadTrustedStep$Execution.run(ReadTrustedStep.java:82)
      	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
      	at hudson.security.ACL.impersonate(ACL.java:260)
      	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      

      This appears to be caused by Bitbucket not recognising PR-86 (the name assigned to it in a multibranch job) as a branch name:

      //https://my.stash.instance.com/rest/api/1.0/projects/xx/repos/yy/browse/pr.groovy?at=PR-86&start=0&limit=500
      
      {
        "errors":[
          {
            "context": null,
            "message": "The path \"pr.groovy\" does not exist at revision \"PR-86\"",
            "exceptionName":"com.atlassian.bitbucket.content.NoSuchPathException"
          }
        ]
      }
      

      Replacing the branch name PR-86 with pull-requests/86/from or pull-requests/86/merge exposes the file.

      Unlike with lightweight checkouts at the start of a build, readTrusted doesn't have a heavyweight checkout to fall back on, so this error causes the build to fail.

            Unassigned Unassigned
            robin_smith Robin Smith
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: