Add Bitbucket API token (Bearer) authentication support - #27
Open
aleks-romanov wants to merge 12 commits into
Open
Add Bitbucket API token (Bearer) authentication support#27aleks-romanov wants to merge 12 commits into
aleks-romanov wants to merge 12 commits into
Conversation
…ry now route through BitbucketAuth
.travis.yml is dead (Travis killed free OSS builds years ago, and the badge even pointed at the wrong org). The Jenkinsfile only builds once this repo is hosted under jenkinsci and picked up by ci.jenkins.io, which doesn't help right now. This adds a working CI that runs today. - .github/workflows/ci.yml: builds and tests inside maven:3.6.3-jdk-8 on every push to master and every PR (this plugin's old parent POM breaks maven-enforcer-plugin under JDK 9+, so this pins the same JDK 8 environment already used for local development). Caches the local Maven repo and uploads the built .hpi as a workflow artifact. - docker/Dockerfile: builds a Jenkins instance with the plugin pre-installed, for testing against a specific real Jenkins/plugin version rather than this plugin's own old baseline. Generic across branches - extra plugin dependencies (e.g. this branch's plain-credentials) are supplied via an EXTRA_PLUGINS build arg, not hardcoded. Standard Jenkins security/setup-wizard flow, nothing disabled or pre-configured. Built and ran it end-to-end (Jenkins 2.555.2, plain-credentials 199.v9f8e1f741799, this branch's actual .hpi) to confirm it actually works, not just that it builds. - README: replaces the dead Travis badge with the new CI badge.
…g/api The legacy bitbucket.org/api/2.0 alias rejects Bearer-token auth with a 401 even with a valid, correctly-scoped token. Confirmed against a real Bitbucket Cloud workspace: the same token succeeds on api.bitbucket.org and fails on bitbucket.org/api on every request.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Bitbucket Cloud is transitioning to API tokens to enhance security. As part of this transition, app passwords were fully deprecated on Jul 28, 2026 - Atlassian changelog, CHANGE-3222
That date has already passed. This plugin currently authenticates exclusively via HTTP Basic Auth (
bitbucket/ApiClient.java), sourced from either a JenkinscredentialsId(StandardUsernamePasswordCredentials) or the legacy plaintextusername/passwordtrigger fields - so this is no longer a future risk, it's a present break: any install of this plugin pointed at Bitbucket Cloud has already lost the ability to authenticate.This PR adds support for the two token mechanisms Bitbucket offers as the replacement:
Authorization: Bearer <token>), so the same mechanism covers it at near-zero marginal cost.What this adds
BitbucketAuthinterface (BasicAuth/BearerAuthimplementations) thatApiClientnow delegates auth to, instead of embedding HTTP Basic Auth directly insend().BasicAuthreproduces the existing behavior exactly;BearerAuthsets anAuthorization: Bearer <token>header and touches nothing else.BitbucketRepositoryresolves the configured Jenkins credential to whicheverBitbucketAuthfits:StandardUsernamePasswordCredentials→BasicAuthas before;StringCredentials("Secret text", from the newplain-credentialsdependency) →BearerAuth.credentialsIddropdown is widened to list both credential kinds - no new UI fields.help-credentialsId.htmldocuments the two credential kinds and a token-scoping caveat.Backward compatibility
No existing configuration changes behavior - Username/Password credentials, the legacy plaintext trigger fields, the Pipeline step's
username/passwordargs, and Server/DC installs are all unchanged. No HTTP client library upgrade.Testing
mvn install), including new coverage forBasicAuth/BearerAuthin isolation, credential-type resolution across both Cloud and Server/DC, and the widened dropdown against a real Jenkins credential store.AssertionErrors) - replaced with a sentinel exception + capture-then-assert pattern, verified by deliberately breaking an assertion and confirming a real failure..hpiagainst a real Jenkins 2.555.2 +plain-credentials 199.v9f8e1f741799(Docker) - confirmed clean load and correct dropdown behavior against production classes, not just this plugin's older parent-POM baseline.Also included: CI + local testing setup
Unrelated to the auth changes above, bundled here because it was built and verified against this same branch's artifact:
.github/workflows/ci.yml- this repo currently has no working CI (.travis.ymlis dead; theJenkinsfileonly activates once hosted underci.jenkins.io). Adds a GitHub Actions build that runs on every push/PR, inside the samemaven:3.6.3-jdk-8environment this plugin already requires.docker/Dockerfile- builds a Jenkins instance with the plugin pre-installed, for testing against a specific real Jenkins/plugin version. Generic (EXTRA_PLUGINSbuild arg), not specific to this PR'splain-credentialsdependency. Built and ran it against Jenkins 2.555.2 +plain-credentials 199.v9f8e1f741799using this branch's actual built.hpi- confirmed clean boot and the plugin loading correctly.README- dead Travis badge replaced with the new CI badge.Notes for reviewers
org.jenkins-ci.plugins:plain-credentials:1.4.Note on how this was built
Developed with Claude Code. I reviewed and directed the design and implementation throughout, including the live testing in the Testing section above. Verification was an actual Docker run against the actual built artifact, not a claim taken on faith.
Submitter checklist