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

Getting clone URL using mirror returns HTTP 401

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • Jenkins: 2.440.1
      cloudbees-bitbucket-branch-source:880.vcf4056c5a_71f

      Bitbucket Version: v8.9.5
    • 933.3.0

      Reproduction steps

      1. Setup multibranch pipeline with ssh checkout of mirror. Using configured admin accesstoken with repo scope.
      2. Jenkins does not use mirror for checkout. Instead it using the primary server

      Expected Results

      Jenkins should use the configured mirror

      Actual Results

      Mirror is not used at all. Fallback to primary server is always used for checkout. In Jenkins log the following is shown:

      Could not determine mirror clone links of xxx on https://xxx for org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject@41d28fe3[Project/XXX] falling back to primary server
      com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException: HTTP request error. Status: 401: .
      HttpResponseProxy{HTTP/1.1 401  [Set-Cookie: BITBUCKETSESSIONID=XXX,
      X-AUSERNAME: access-token-user%2F2%2FXXXX, 
      X-ASESSIONID: XXXX,
      WWW-Authenticate: OAuth realm="https%3A%2F%2Fmirror-url", ...] org.apache.http.client.entity.DecompressingEntity@6fb61eb7}
      	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getRequest(BitbucketServerAPIClient.java:987)
      	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getMirroredRepository(BitbucketServerAPIClient.java:499)
      	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.getCloneLinksFromMirror(BitbucketSCMSource.java:1278)
      	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.initMirrorCloneLinks(BitbucketSCMSource.java:1244)
      	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.initCloneLinks(BitbucketSCMSource.java:1238)
      	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.build(BitbucketSCMSource.java:1027)
      ... 

      The URL which is used in BitbucketServerAPIClient.getMirroredRepository contains already a jwt in the query parameter:
      https://MIRROR_URL/rest/mirroring/latest/upstreamServers/XXX/repos/XXX?jwt=TOKEN.
      If i used this URL for example with curl https://MIRROR_URL/rest/mirroring/latest/upstreamServers/XXX/repos/XXX?jwt=TOKEN the request is successful.

       

      The API documentation of the endpoint which returns the URL of the mirror.
      (https://developer.atlassian.com/server/bitbucket/rest/v803/api-group-mirroring/#api-mirroring-latest-repos-repoid-mirrors-get) says the URL contains already the authorization link to the mirror. The additional authenticator configuration is not needed.

       

            nfalco Nikolas Falco
            nfalco Nikolas Falco
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: