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

Getting clone URL using mirror returns HTTP 401

    • 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.

       

          [JENKINS-75089] Getting clone URL using mirror returns HTTP 401

          Nikolas Falco created issue -
          Nikolas Falco made changes -
          Summary Original: Clone URL using mirror returns HTTP 401 New: Getting clone URL using mirror returns HTTP 401
          Nikolas Falco made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Nikolas Falco made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: In Progress [ 3 ] New: Fixed but Unreleased [ 10203 ]
          Nikolas Falco made changes -
          Released As New: 933.3.0
          Status Original: Fixed but Unreleased [ 10203 ] New: Closed [ 6 ]

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

              Created:
              Updated:
              Resolved: