jenkinsci/bitbucket-branch-source-plugin

Bitbucket Cloud - Unable to read branches with multibranch pipeline with credentials - Error while loading repositories from cache

jackkitley opened this issue · 1 comments

Jenkins and plugins versions report

Environment
Jenkins: 2.319.3
OS: Linux - 5.11.0-1022-aws
---
ace-editor:1.1
ant:1.13
antisamy-markup-formatter:2.7
apache-httpcomponents-client-4-api:4.5.13-1.0
authentication-tokens:1.4
aws-credentials:189.v3551d5642995
aws-java-sdk-ec2:1.12.148-310.v5e3b_c2681d79
aws-java-sdk-minimal:1.12.148-310.v5e3b_c2681d79
bitbucket:214.v2fd4234d0554
blueocean-bitbucket-pipeline:1.25.2
blueocean-commons:1.25.2
blueocean-core-js:1.25.2
blueocean-jwt:1.25.2
blueocean-pipeline-api-impl:1.25.2
blueocean-pipeline-scm-api:1.25.2
blueocean-rest:1.25.2
blueocean-rest-impl:1.25.2
blueocean-web:1.25.2
bootstrap4-api:4.6.0-3
bootstrap5-api:5.1.3-6
bouncycastle-api:2.25
branch-api:2.7.0
build-timeout:1.20
caffeine-api:2.9.2-29.v717aac953ff3
checks-api:1.7.2
cloudbees-bitbucket-branch-source:756.v081ee2205040
cloudbees-folder:6.708.ve61636eb_65a_5
command-launcher:1.6
credentials:1074.v60e6c29b_b_44b_
credentials-binding:1.27.1
display-url-api:2.3.5
durable-task:493.v195aefbb0ff2
echarts-api:5.3.0-2
email-ext:2.87
favorite:2.3.3
font-awesome-api:6.0.0-1
git:4.10.3
git-client:3.11.0
git-server:1.10
github:1.34.2
github-api:1.301-378.v9807bd746da5
github-branch-source:2.11.4
gradle:1.38
handlebars:3.0.8
handy-uri-templates-2-api:2.1.8-1.0
htmlpublisher:1.29
jackson2-api:2.13.1-246.va8a9f3eaf46a
javax-activation-api:1.2.0-2
javax-mail-api:1.6.2-5
jdk-tool:1.5
jenkins-design-language:1.25.2
jjwt-api:0.11.2-9.c8b45b8bb173
jnr-posix-api:3.1.7-1
jquery3-api:3.6.0-2
jsch:0.1.55.2
junit:1.54
ldap:2.8
lockable-resources:2.14
mailer:408.vd726a_1130320
matrix-auth:3.0.1
matrix-project:1.20
mercurial:2.16
momentjs:1.1.1
okhttp-api:4.9.3-105.vb96869f8ac3a
pam-auth:1.7
pipeline-build-step:2.16
pipeline-github-lib:36.v4c01db_ca_ed16
pipeline-graph-analysis:188.v3a01e7973f2c
pipeline-input-step:446.vf27b_0b_83500e
pipeline-milestone-step:100.v60a_03cd446e1
pipeline-model-api:1.9.3
pipeline-model-definition:1.9.3
pipeline-model-extensions:1.9.3
pipeline-rest-api:2.21
pipeline-stage-step:291.vf0a8a7aeeb50
pipeline-stage-tags-metadata:1.9.3
pipeline-stage-view:2.21
plain-credentials:1.8
plugin-util-api:2.14.0
popper-api:1.16.1-2
popper2-api:2.11.2-1
pubsub-light:1.16
resource-disposer:0.17
scm-api:595.vd5a_df5eb_0e39
script-security:1131.v8b_b_5eda_c328e
snakeyaml-api:1.29.1
ssh-credentials:1.19
ssh-slaves:1.33.0
sshd:3.1.0
structs:308.v852b473a2b8c
timestamper:1.17
token-macro:277.v7c8f82a_d66b_3
trilead-api:1.0.13
variant:1.4
workflow-aggregator:2.6
workflow-api:1138.v619fd5201b_2f
workflow-basic-steps:2.24
workflow-cps:2659.v52d3de6044d0
workflow-cps-global-lib:564.ve62a_4eb_b_e039
workflow-durable-task-step:1121.va_65b_d2701486
workflow-job:1145.v7f2433caa07f
workflow-multibranch:711.vdfef37cda_816
workflow-scm-step:2.13
workflow-step-api:622.vb_8e7c15b_c95a_
workflow-support:813.vb_d7c3d2984a_0
ws-cleanup:0.40

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

AWS EC2 ubuntu 20

Reproduction steps

  1. I went to my bitbucket cloud and when into account settings and created a new app password with project read and webhook read.
  2. I took the pass phrase and in jenkins admin i added new credentials. the username is my email address i use to login to cloud and the password is the clipboard password from bitbucket cloud app passwords.
  3. I then went to mange jenkins and i added a new bitbucket cloud setting with my credentials i added in step 2 and the url is my jenkins URL.
  4. I went to create a new multibranch pipeline. under branch sources i select my credentials and the server url is already populated.

The problem is where i type owner. I type in my email address and also try my username but it keeps returning

Error while loading repositories from cache

  • OR -
    user not found

Expected Results

i expect my branches to be listed or my projects.

Actual Results

it shows

Error while loading repositories from cache

and if i click save it shows this in console:

Started
[Wed Feb 23 19:08:31 UTC 2022] Starting branch indexing...
ERROR: [Wed Feb 23 19:08:32 UTC 2022] Could not update folder level actions from source 5b662488-8709-40e7-890e-148e84ada3e6
[Wed Feb 23 19:08:32 UTC 2022] Finished branch indexing. Indexing took 1 sec
FATAL: Failed to recompute children of bitbucket-auth
com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException: HTTP request error. Status: 401: Unauthorized.

	at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRequestAsInputStream(BitbucketCloudApiClient.java:911)
	at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRequest(BitbucketCloudApiClient.java:923)
	at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRepository(BitbucketCloudApiClient.java:389)
	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieveActions(BitbucketSCMSource.java:1015)
	at jenkins.scm.api.SCMSource.fetchActions(SCMSource.java:848)
	at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:598)
	at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:278)
	at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:166)
	at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1032)
	at hudson.model.ResourceController.execute(ResourceController.java:99)
	at hudson.model.Executor.run(Executor.java:432)
Finished: FAILURE

Anything else?

2022-02-23 19:24:02.530+0000 [id=92] INFO o.a.h.impl.execchain.RetryExec#execute: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {s}->https://api.bitbucket.org:443: The target server failed to respond
2022-02-23 19:24:02.530+0000 [id=92] INFO o.a.h.impl.execchain.RetryExec#execute: Retrying request to {s}->https://api.bitbucket.org:443

2022-02-23 19:24:03.559+0000 [id=92] INFO o.a.h.impl.execchain.RetryExec#execute: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {s}->https://api.bitbucket.org:443: The target server failed to respond
2022-02-23 19:24:03.560+0000 [id=92] INFO o.a.h.impl.execchain.RetryExec#execute: Retrying request to {s}->https://api.bitbucket.org:443
2022-02-23 19:24:04.609+0000 [id=92] SEVERE c.c.j.p.b.BitbucketSCMSource$DescriptorImpl#doFillRepositoryItems: Error while loading repositories from cache
org.apache.http.NoHttpResponseException: api.bitbucket.org:443 failed to respond
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpRespons

I figured out what the issue was here.

  1. The owner can either be you as the user, so your username and then it lists your repo's.
  2. The owner can also be the 'workspace' you belong to and this is what was throwing me off as the documentation used a different word im not used to.

I had to go use the bitbucket api in postman to figure out what it wanted but eventually sorted it out.

Also, my username was my profile username for authentication. It didnt want to accept my email address as a username which is odd as i login with it.