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

Unable to build PR from private fork in BitbucketServer

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • bitbucket-branch-source-plugin 2.2.2

      With new 2.x version of the plugin, the scan has no authentication problem (JENKINS-40465):

      [lun. juil. 24 18:40:03 CEST 2017] Starting branch indexing...
      Connecting to http://bitbucket.mycompany.com using user/******
      Repository type: Git
      Looking up PROJECT/test_jenkins_pr for branches
      Checking branch local_pr from PROJECT/test_jenkins_pr
      Checking branch master from PROJECT/test_jenkins_pr
            'Jenkinsfile' found
          Met criteria
      No changes detected: master (still at 4c553423451313f310236bb6afda201ec93f8641)
      
        2 branches were processed
      Looking up PROJECT/test_jenkins_pr for pull requests
      Checking PR-1 from PROJECT/test_jenkins_pr and branch local_pr
            'Jenkinsfile' found
          Met criteria
      No changes detected: PR-1 (still at f7eb292cc308ffb31145ad30c4e0e5ed7c946d51)
      Checking PR-2 from ~zigarn/test_jenkins_pr and branch remote_pr
            'Jenkinsfile' found
          Met criteria
      No changes detected: PR-2 (still at 2175b660d8055ea35bdd391eb912f8fa7475efb1)
      
        2 pull requests were processed
      [lun. juil. 24 18:40:23 CEST 2017] Finished branch indexing. Indexing took 19 s
      Finished: SUCCESS
      

      But, the build has problem:

      java.io.IOException: I/O error when accessing URL: /rest/api/1.0/projects/~zigarn/repos/test_jenkins_pr/branches?start=0
      	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getBranches(BitbucketServerAPIClient.java:378)
      	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieve(BitbucketSCMSource.java:769)
      	at jenkins.scm.api.SCMSource.fetch(SCMSource.java:564)
      	at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:79)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:214)
      	at hudson.model.ResourceController.execute(ResourceController.java:98)
      	at hudson.model.Executor.run(Executor.java:410)
      Caused by: com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException: HTTP request error. Status: 401: Unauthorized.
      {"errors":[{"context":null,"message":"You are not permitted to access this resource","exceptionName":"com.atlassian.bitbucket.AuthorisationException"}]}
      	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getRequest(BitbucketServerAPIClient.java:516)
      	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getBranches(BitbucketServerAPIClient.java:363)
      	... 6 more
      Finished: FAILURE
      

      The scan use the PR target owner and repository but store the PR source owner and repository, and when when building it's trying to get the branches from this source repository but access is not allowed.

            Unassigned Unassigned
            zigarn Alexandre Garnier
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: