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

Frequent 401 errors from Bitbucket Data Center when there are high concurrent builds

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • Jenkins version: 2.479.3
      Bitbucket Branch Source Plugin version: 935.1.3
      Bitbucket Data Center version: 8.19.14
    • 936.4.2

      We are experiencing repeated 401 Unauthorized errors when Jenkins attempts to access Bitbucket repositories using the Bitbucket Branch Source Plugin. This issue started occurring very frequent since Feb 2025.

      The errors appear during branch indexing and job execution, and are consistent across different repositories. The responses from Bitbucket indicate an AuthorisationException, despite valid credentials and previously working configuration. When we run the job again, it works without any changes. 

      Also why OAuth authentication is being used?

      Observed Jenkins Log Output:

      com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource getProjectKey
      Failure getting the project key of repository <repo_name_redacted> : 
      HTTP request error.
      Status: HTTP/1.1 401 
      Response: {
        "errors": [
          {
            "context": null,
            "message": "You are not permitted to access this resource",
            "exceptionName": "com.atlassian.bitbucket.AuthorisationException"
          }
        ]
      }
      Server: nginx/1.26.0
      Date: Mon, 24 Mar 2025 10:12:15 GMT
      WWW-Authenticate: OAuth realm="https%3A%2F%2F<bitbucket-hostname-redacted>"
      Set-Cookie: BITBUCKETSESSIONID=[REDACTED] 

      Observed Job Console Output:

      17:10:05  Branch event17:10:05  com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException: HTTP request error.17:10:05  Status: HTTP/1.1 40117:10:05  Response: {"errors":[{"context":null,"message":"You are not permitted to access this resource","exceptionName":"com.atlassian.bitbucket.AuthorisationException"}]}17:10:05  Server: nginx/1.26.017:10:05  Date: Sun, 23 Mar 2025 16:10:05 GMT17:10:05  Content-Type: application/json;charset=UTF-817:10:05  Transfer-Encoding: chunked17:10:05  Connection: keep-alive17:10:05  X-AREQUESTID: <redacted>:10:05  Set-Cookie: BITBUCKETSESSIONID=<redacted>; Max-Age=1209600; Expires=Sun, 06 Apr 2025 16:10:05 GMT; Path=/; Secure; HttpOnly17:10:05  X-ASESSIONID: 130unb17:10:05  Cache-Control: private, no-cache17:10:05  Pragma: no-cache17:10:05  Cache-Control: no-cache, no-transform17:10:05  Vary: x-ausername,x-auserid,cookie,accept-encoding17:10:05  WWW-Authenticate: OAuth realm="https%3A%2F%2F<bitbucket-hostname-redacted>"17:10:05    at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.impl.client.AbstractBitbucketApi.buildResponseException(AbstractBitbucketApi.java:90)17:10:05    at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.impl.client.AbstractBitbucketApi.doRequest(AbstractBitbucketApi.java:237)17:10:05    at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.impl.client.AbstractBitbucketApi.doRequest(AbstractBitbucketApi.java:250)17:10:05    at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.impl.client.AbstractBitbucketApi.getRequest(AbstractBitbucketApi.java:292)17:10:05    at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getResource(BitbucketServerAPIClient.java:905)17:10:05    at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getSingleBranch(BitbucketServerAPIClient.java:625)17:10:05    at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getBranch(BitbucketServerAPIClient.java:590)17:10:05    at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getBranch(BitbucketServerAPIClient.java:110)17:10:05    at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieve(BitbucketSCMSource.java:925)17:10:05    at PluginClassLoader for scm-api//jenkins.scm.api.SCMSource.fetch(SCMSource.java:581)17:10:05    at PluginClassLoader for workflow-multibranch//org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:104)17:10:05    at PluginClassLoader for workflow-job//org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:319)17:10:05    at hudson.model.ResourceController.execute(ResourceController.java:101)17:10:05    at hudson.model.Executor.run(Executor.java:445)17:10:06  Finished: FAILURE 

       

       

            nfalco Nikolas Falco
            sbb_wzu MWZ-WZU SBB
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: