App passwords will be replaced by API tokens in bitbucket - API token not working for multibranch pipeline

Hi,

We already have a working Jenkins setup which currently uses Bitbucket App password to clone repositories. Same secret is also in multibranch pipelines. Everythig works fine.

Now I am trying to replace this secret by a secret created by using Bitbucket API token. I have created a Jenkins secret in which username is same as my Bitbucket username and password is Bitbucket API token. This secret is working fine in normal pipeline. Repository is being cloned and pipeline runs successfuly. But when I use this secret in multibranch pipeline, it is not able to show me list of repositories in my bitbucket account. Seems it is not able to fetch the list of repositories. So, I am not able to create/configure my multibranch pipeline.

I created another secret using the same API token, but this time I used my email id as username. When I use this secret in multibranch pipeline list of repositories is being populated and I am able to create the multibranch pipeline. But when a multibranch pipeline is trigged and it reaches the stage where git plugin needs to clone the repository, it fails because of failure from Git plugin related to authentication. So, cloning of repository fails.

There is no issue with the scopes associated with the token. Token has following scopes:

read:repository:bitbucket
read:pullrequest:bitbucket
read:webhook:bitbucket
write:webhook:bitbucket

In summary, it seems “Bitbucket Branch Source Plugin” which is used for multibranch pipeline needs secret in which email is used as username and Git plugin needs secret in which bitbucket username is used as username. Now, I am not sure how to meet requirements of both so that multibranch pipelines run successfully.

Jenkins setup:
Jenkins: 2.509
OS: Linux - 5.10.237-230.949.amzn2.x86_64
Java: 21.0.7 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)

antisamy-markup-formatter:173.v680e3a_b_69ff3
apache-httpcomponents-client-4-api:4.5.14-269.vfa_2321039a_83
apache-httpcomponents-client-5-api:5.5-150.veb_76e719855b_
asm-api:9.8-135.vb_2239d08ee90
authentication-tokens:1.131.v7199556c3004
blueocean-commons:1.27.21
blueocean-core-js:1.27.21
blueocean-rest:1.27.21
bootstrap5-api:5.3.7-1
bouncycastle-api:2.30.1.80-261.v00c0e2618ec3
branch-api:2.1226.ve1e7e0b_4b_95f
build-timeout:1.38
caffeine-api:3.2.0-166.v72a_6d74b_870f
checks-api:373.vfe7645102093
cloudbees-bitbucket-branch-source:936.4.2
cloudbees-disk-usage-simple:241.v0ea_d9a_a_96ee8
cloudbees-folder:6.1026.ve06dfa_cf31c3
command-launcher:123.v37cfdc92ef67
commons-lang3-api:3.17.0-87.v5cf526e63b_8b_
commons-text-api:1.13.1-176.v74d88f22034b_
config-file-provider:988.v0461fcc2b_9d1
configuration-as-code:1971.vf9280461ea_89
credentials:1415.v831096eb_5534
credentials-binding:687.v619cb_15e923f
dark-theme:524.vd675b_22b_30cb_
dashboard-view:2.528.v3470c02b_d7c9
dependency-check-jenkins-plugin:5.6.1
display-url-api:2.209.v582ed814ff2f
docker-commons:457.v0f62a_94f11a_3
docker-workflow:621.va_73f881d9232
durable-task:587.v84b_877235b_45
echarts-api:5.6.0-5
eddsa-api:0.3.0.1-19.vc432d923e5ee
email-ext:1911.v19b_8e86f9815
favorite:2.237.v79163ca_8b_892
font-awesome-api:6.7.2-1
git:5.7.0
git-client:6.2.0
github:1.43.0
github-api:1.321-488.v9b_c0da_9533f8
github-branch-source:1824.v046257273408
gson-api:2.13.1-139.v4569c2ef303f
handy-uri-templates-2-api:2.1.8-36.v85e4cb_234a_13
htmlpublisher:425
instance-identity:203.v15e81a_1b_7a_38
ionicons-api:88.va_4187cb_eddf1
jackson2-api:2.19.0-404.vb_b_0fd2fea_e10
jakarta-activation-api:2.1.3-2
jakarta-mail-api:2.1.3-2
javax-activation-api:1.2.0-8
javax-mail-api:1.6.2-11
jaxb:2.3.9-133.vb_ec76a_73f706
jenkins-design-language:1.27.21
jjwt-api:0.11.5-120.v0268cf544b_89
job-dsl:1.93
joda-time-api:2.14.0-127.v7d9da_295a_d51
jquery:1.12.4-3
jquery3-api:3.7.1-3
json-api:20250517-153.vc8a_a_d87c0ce3
json-path-api:2.9.0-148.v22a_7ffe323ce
jsoup:1.21.1-52.v96e4041b_60fd
junit:1335.v6b_a_a_e18534e1
kubernetes:4358.vcfd9c5a_0a_f51
kubernetes-client-api:7.3.1-256.v788a_0b_787114
kubernetes-credentials:203.v85b_9836a_f44b_
mailer:509.vc54d23fc427e
matrix-project:849.v0cd64ed7e531
metrics:4.2.32-476.v5042e1c1edd7
mina-sshd-api-common:2.15.0-161.vb_200831a_c15b_
mina-sshd-api-core:2.15.0-161.vb_200831a_c15b_
nodejs:1.6.5
oic-auth:4.520.v7208b_4ff730b_
okhttp-api:4.11.0-189.v976fa_d3379d6
parameterized-scheduler:285.ve611986d4c48
pipeline-build-step:571.v08a_fffd4b_0ce
pipeline-graph-analysis:241.vc3d48fb_b_2582
pipeline-graph-view:590.v06d574696250
pipeline-groovy-lib:752.vdddedf804e72
pipeline-input-step:527.vd61b_1d3c5078
pipeline-milestone-step:138.v78ca_76831a_43
pipeline-model-api:2.2255.v56a_15e805f12
pipeline-model-definition:2.2255.v56a_15e805f12
pipeline-model-extensions:2.2255.v56a_15e805f12
pipeline-rest-api:2.38
pipeline-stage-step:322.vecffa_99f371c
pipeline-stage-tags-metadata:2.2255.v56a_15e805f12
pipeline-stage-view:2.38
plain-credentials:199.v9f8e1f741799
plugin-util-api:6.1.0
prism-api:1.30.0-1
prometheus:819.v50953a_c560dd
pubsub-light:1.19
resource-disposer:0.25
role-strategy:785.v8d262df0f607
scm-api:704.v3ce5c542825a_
script-security:1373.vb_b_4a_a_c26fa_00
snakeyaml-api:2.3-125.v4d77857a_b_402
sonar:2.18
sse-gateway:1.28
ssh-credentials:359.v2191c4cf635f
sshd:3.372.v5d04a_e92d8cf
structs:350.v3b_30f09f2363
theme-manager:310.v234c7de84f9c
timestamper:1.30
token-macro:444.v52de7e9c573d
trilead-api:2.209.v0e69b_c43c245
variant:70.va_d9f17f859e0
workflow-api:1373.v7b_813f10efa_b_
workflow-basic-steps:1079.vce64b_a_929c5a_
workflow-cps:4150.ve20ca_b_a_a_2815
workflow-durable-task-step:1434.v1b_595c29ddd7
workflow-job:1540.v295eccc9778f
workflow-multibranch:806.vb_b_688f609ee9
workflow-scm-step:437.v05a_f66b_e5ef8
workflow-step-api:700.v6e45cb_a_5a_a_21
workflow-support:968.v8f17397e87b_8
ws-cleanup:0.48

Seems there is already a ticket on Bitbucket Branch Source Plugin for this issue: