jenkinsci / bitbucket-branch-source-plugin

Bitbucket Branch Source Plugin
https://plugins.jenkins.io/cloudbees-bitbucket-branch-source
MIT License
217 stars 352 forks source link

Branches auto-discovering not working on Bitbucket server #799

Open maannima opened 8 months ago

maannima commented 8 months ago

Jenkins and plugins versions report

Environment ```text Bitbucket Server v8.9.6 Jenkins 2.426.2 OS: Linux - 4.18.0-372.80.1.el8_6.x86_64 Java: 17.0.9 - Eclipse Adoptium (OpenJDK 64-Bit Server VM) Bitbucket Branch Source Plugin 856.v04c46c86f911 Pipeline: Multibranch 756.v891d88f2cd46 ```

What Operating System are you using (both controller, and any agents involved in the problem)?

Bitbucket Server v8.9.6 Jenkins 2.426.2 OS: Linux - 4.18.0-372.80.1.el8_6.x86_64 Java: 17.0.9 - Eclipse Adoptium (OpenJDK 64-Bit Server VM) Bitbucket Branch Source Plugin 856.v04c46c86f911 Pipeline: Multibranch 756.v891d88f2cd46

Reproduction steps

Setup a multi-branch project with a Single repository source

Get credentials to access the Bitbucket API

Create a Bitbucket HTTP access tokens (project admin)

image

Bitbucket Endpoints configuration in Jenkins > Manage Jenkins

Added Jenkins Credentials:

image

Configure the multi-branch project source

image

Expected Results

Expected was a working integration between Jenkins and Bitbucket server. But the Repository Name in Branch Sources can't be filled in and doesn't show a drop down.

Actual Results

Repository Name in Branch Sources can't be filled in and doesn't show a drop down. image

Anything else?

As a result the Scan Multibranch Pipeline Logs show the following

[Wed Jan 17 13:54:57 UTC 2024] Starting branch indexing... ERROR: [Wed Jan 17 13:54:57 UTC 2024] Could not update folder level actions from source f0326964-f8d1-41b6-9041-46ce232fcc15 [Wed Jan 17 13:54:57 UTC 2024] Finished branch indexing. Indexing took 9 ms FATAL: Failed to recompute children of tests » stack-aws-container-registery-maianni1-test com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException: HTTP request error. Status: 403: . HttpResponseProxy{HTTP/1.1 403 [Date: Wed, 17 Jan 2024 13:54:57 GMT, Content-Type: application/json;charset=UTF-8, Content-Length: 70, Connection: keep-alive, Set-Cookie: AWSALB=z+cAOlLFOnOuMM++etnNvbLkfogJt4wOp3Tm97i//z27yGJr+O+qiXCSfSXCM5R1TLM7H+Yq+PnGj0+UTeZsn4ovzEcfYktOOMRSbJFalpsFKoQsQ5hFBCturSlE; Expires=Wed, 24 Jan 2024 13:54:57 GMT; Path=/, Set-Cookie: AWSALBCORS=z+cAOlLFOnOuMM++etnNvbLkfogJt4wOp3Tm97i//z27yGJr+O+qiXCSfSXCM5R1TLM7H+Yq+PnGj0+UTeZsn4ovzEcfYktOOMRSbJFalpsFKoQsQ5hFBCturSlE; Expires=Wed, 24 Jan 2024 13:54:57 GMT; Path=/; SameSite=None; Secure, X-AREQUESTID: *VA1LQ8x834x14525318x1] ResponseEntityProxy{[Content-Type: application/json;charset=UTF-8,Content-Length: 70,Chunked: false]}} at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getRequest(BitbucketServerAPIClient.java:978) at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getRepository(BitbucketServerAPIClient.java:494) at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieveActions(BitbucketSCMSource.java:1107) at jenkins.scm.api.SCMSource.fetchActions(SCMSource.java:847) at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:611) at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:269) at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:167) at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1057) at hudson.model.ResourceController.execute(ResourceController.java:101) at hudson.model.Executor.run(Executor.java:442) Finished: FAILURE

Are you interested in contributing a fix?

No response

andygoossens commented 7 months ago

You claim to be using Bitbucket Server, but I assume that is a mistake on your part. Only Bitbucket Data Center has support for HTTP access tokens on project/repository level: https://confluence.atlassian.com/bitbucketserver089/http-access-tokens-1236435579.html#HTTPaccesstokens-CreateHTTPaccesstokensforprojectsorrepositories

maannima commented 7 months ago

The differentiation I'm aware of is between Bitbucket Server and Bitbucket Cloud. Bitbucket Server is a self-hosted solution, often deployed in a Data Center. This is the method I am using.