Repository navigation
feat: Support Bitbucket Cloud repository access tokens - #3010
Conversation
Paco Review 🔍This PR adds support for Bitbucket Cloud workspace and repository access tokens (prefixed with Review difficulty: 3/5 (Moderate) — The change is moderate in size and touches authentication logic, ACL enforcement, and secret generation across several packages, but each piece is well-scoped and individually testable. 3 new inline comment(s) found. Reviewed commit: 17377af |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3010 +/- ##
==========================================
+ Coverage 91.95% 91.97% +0.02%
==========================================
Files 167 167
Lines 12954 12965 +11
==========================================
+ Hits 11912 11925 +13
+ Misses 1041 1039 -2
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The access-token permission instructions use API-token scope names that are unavailable during resource-token creation.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Adds Bitbucket Cloud workspace/repository access-token support across API authentication, Git checkout, ACL handling, and documentation.
Changes:
- Detects
ATCTtokens and uses bearer authentication. - Uses
x-token-authfor Git credentials. - Adds ACL fallback and tests for restricted membership access.
| File | Description |
|---|---|
pkg/vcshost/vcshost_test.go |
Uses canonical host constants. |
pkg/secrets/basic_auth.go |
Selects the access-token Git username. |
pkg/secrets/basic_auth_test.go |
Tests generated access-token credentials. |
pkg/provider/bitbucketcloud/bitbucket.go |
Configures bearer authentication. |
pkg/provider/bitbucketcloud/bitbucket_test.go |
Verifies authorization headers. |
pkg/provider/bitbucketcloud/acl.go |
Handles unavailable membership lookup and securely reads default-branch OWNERS files. |
pkg/provider/bitbucketcloud/acl_test.go |
Covers access-token authorization paths. |
pkg/cmd/tknpac/webhook/update-token.go |
Reuses the canonical Bitbucket hostname. |
docs/content/docs/providers/bitbucket-cloud.md |
Documents resource access-token setup. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
66723c1 to
a20ed5a
Compare
|
closing this as we cannot test this at this time, feel free to reopen if someone asks for this... |
|
project level feature is testable |
17377af to
29f493c
Compare
5246f70 to
6a7ea4c
Compare
| - **Webhooks: Write** | ||
|
|
||
| {{< callout type="warning" >}} | ||
| A repository access token cannot list workspace members, so workspace |
There was a problem hiding this comment.
@chmouel I see only one way of getting user's account id is seeing webhook payload and getting accound id out of it but I think we shoud sepcify here how to get account id in easy way so and with repo access token it's not accessible as /2.0/user endpoint in bitbucket api is not allowed by repo access token. saying that how to get one's account id so that we can specify the way to get it in this docs?
There was a problem hiding this comment.
@chmouel can you please take a look? and we're good to go...
There was a problem hiding this comment.
@chmouel can you please take a look? and we're good to go...
this is documented here, anything missed? https://github.com/tektoncd/pipelines-as-code/pull/3010/changes#diff-549bbed8b30913afbf55052b9fed1614225cea101641a71224c3b2630afe050aR59 (line 59)
6a7ea4c to
b33523f
Compare
|
Error is a 502 on github and we don't have enable-api-retry by default on e2e #3039 |
ddff04d to
d85fd3e
Compare
d85fd3e to
137729a
Compare
137729a to
7268574
Compare
7268574 to
df25aa9
Compare
|
@zakisk good for you? |
I was waiting for you here #3010 (comment) |
df25aa9 to
9ac8740
Compare
Bitbucket Cloud repository access tokens can now be used in place of a personal API token. Pipelines-as-Code recognizes these tokens on its own and signs in to Bitbucket and clones the repository the way Bitbucket expects for them, so no extra setting is needed. These tokens are not allowed to look up who belongs to the workspace. When that check is refused, Pipelines-as-Code now relies on the OWNERS files and /ok-to-test comments to decide who may run pipelines, instead of failing the whole run. Jira: https://redhat.atlassian.net/browse/SRVKP-14667 Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com> AI-assisted-by: GitHub Copilot
9ac8740 to
9bd6fd6
Compare

📝 Description of the Change
You can now use a Bitbucket Cloud repository access token in the Repository CR instead of a personal API token. Pipelines-as-Code recognizes these tokens by their
ATCTprefix and signs in to Bitbucket and clones the repository the way Bitbucket expects for them. No extra setting is needed.A repository access token cannot see who belongs to the workspace. When Bitbucket refuses that lookup, Pipelines-as-Code falls back to the
OWNERSfiles and/ok-to-testcomments to decide who may run pipelines, so the event still gets processed. ThoseOWNERSfiles are now always read from the default branch, so a pull request cannot approve itself by editing them.Workspace and project access tokens use the same prefix, but they need a Bitbucket Premium plan and we cannot test them, so this PR does not document or claim support for them.
🔗 Linked GitHub Issue
Jira: SRVKP-14667
🧪 Testing Strategy
🤖 AI Assistance
AI assistance can be used for various tasks, such as code generation,
documentation, or testing.
Please indicate whether you have used AI assistance
for this PR and provide details if applicable.
Important
Slop will be simply rejected, if you are using AI assistance you need to make sure you
understand the code generated and that it meets the project's standards. you
need at least know how to run the code and deploy it (if needed). See
startpaac to make it easy
to deploy and test your code changes.
If the majority of the code in this PR was generated by an AI, please add a
Co-authored-bytrailer to your commit message.For example:
Co-authored-by: Claude noreply@anthropic.com
✅ Submitter Checklist
fix:,feat:) matches the "Type of Change" I selected above.make testandmake lintlocally to check for and fix anyissues. For an efficient workflow, I have considered installing
pre-commit and running
pre-commit installtoautomate these checks.