Bitbucket
Bitbucket Cloud is a code platform: kōjō takes requests there from mentions in pull requests and from the events you map to skills, answers in comments, and opens pull requests. Bitbucket Data Center has another API and is not supported.
Bitbucket Cloud has no issues: Atlassian removed its issue tracker, from the web and from the API, in August 2026. On Bitbucket, kōjō works from pull requests, chat, the CLI, the dashboard and schedules; a skill that lists issues gets an error that says so.
See Surfaces for how Bitbucket compares with the other code platforms, and Who may trigger what for whose requests may change code.
Set up
-
Create a dedicated Atlassian account for the bot and add it to the workspace. It is the account people mention, and it authors kōjō’s pull requests, commits and comments.
-
Give the bot write access to the repositories it works on, and make it an administrator of each repository. Bitbucket only tells repository administrators what access other users have, and kōjō needs that to decide who may trigger what. Reading branch restrictions needs it too.
-
Signed in as the bot, create an API token with scopes: Account settings, Security, Create and manage API tokens, Create API token with scopes, with Bitbucket as the app. It can be limited to the workspace. Give it these scopes:
Scope Used for read:user:bitbucketKnowing which account the bot is read:repository:bitbucketRepositories, branches, files, commit statuses, permissions write:repository:bitbucketBranches and commits admin:repository:bitbucketBranch restrictions read:pullrequest:bitbucketPull requests, their comments and diffs write:pullrequest:bitbucketOpening, editing, commenting on and merging pull requests read:pipeline:bitbucketBitbucket Pipelines logs for follow-ups An API token expires on the date you chose when you created it; replace it before then.
-
Add Bitbucket to
kojo.yaml. All three keys are required.workspaceis the workspace ID, the first part ofbitbucket.org/<workspace>/<repository>: the dashboard lists that workspace’s repositories.forges: bitbucket: workspace: acme token: ${BITBUCKET_TOKEN} webhook_secret: ${BITBUCKET_WEBHOOK_SECRET} -
In each repository’s settings, under Webhooks, add a webhook with the URL
<public_url>/webhooks/bitbucketand the secret set to the value ofwebhook_secret. Choose the triggers in the table below. -
Enable the repositories in the dashboard as
bitbucket/workspace/repository. -
Run
kojo doctor. It checks that the API accepts the token and that the bot can list the workspace’s repositories. A token’s scopes cannot be read back, so a token that lacks one only shows in the first call that needs it. For each enabled repository the checktrigger permissions <repo>fails when kōjō cannot read user permissions there, which on Bitbucket means the bot is not an administrator of the repository. No mention can be authorized on such a repository.
There is no kojo setup command for Bitbucket: an API token is created by the account that owns it, in the browser.
Accounts and mentions
Bitbucket accounts have no login that kōjō can use: names are not unique, and usernames are gone from the API. kōjō names a Bitbucket account by its Atlassian account ID, for example 557058:c0b72ad0-1cb5-4018-9cdc-0cde8492c443. That ID is what the dashboard and the audit log show as the actor, and what links a person’s Bitbucket account to their email in per-person memory (bitbucket:<account ID>).
To mention the bot, type @ and pick it from the list Bitbucket offers. Bitbucket writes the mention into the comment as @{<account ID>}, which is what kōjō looks for. An @name typed without picking the account is plain text and mentions nobody.
Events
X-Event-Key |
Becomes |
|---|---|
pullrequest:comment_created |
A mention, when the comment mentions the bot. Any other comment is feedback: pr_review_comment for a comment on a line of the diff, with its file and line, and pr_comment otherwise |
pullrequest:created |
pr_opened, or a mention when the description mentions the bot |
pullrequest:push |
pr_updated |
pullrequest:fulfilled |
pr_closed: the pull request was merged |
pullrequest:rejected |
pr_closed: the pull request was declined |
repo:commit_status_created, repo:commit_status_updated (state FAILED) |
check_failed, Bitbucket Pipelines included |
repo:push to a branch |
A reload of .factory/, when the branch is the main branch |
In the webhook’s settings these are, under Pull Request, Comment created, Created, Pushed, Merged and Declined, and under Repository, Push, Build status created and Build status updated.
Bitbucket does not document the payload of pullrequest:push; kōjō reads the actor, the pull request and the repository from it, as from the other pull request events. pullrequest:updated is not used: its payload does not say what changed. So a pull request marked ready for review starts nothing, unlike GitHub’s ready_for_review. An approval or a request for changes carries no text, so neither is feedback.
Webhook
Bitbucket signs each delivery with the webhook’s secret: X-Hub-Signature is sha256= and the hex HMAC-SHA256 of the body. kōjō compares it in constant time before it decodes anything, and refuses any other hash. X-Request-UUID is the delivery ID that de-duplicates redeliveries.
The status codes kōjō answers a delivery with are the same for every forge: see webhook responses.
Follow-ups
On a pull request kōjō opened, a mention, or a failed build where the repository opts in, starts a follow-up that commits to the pull request’s branch. What it uses on Bitbucket:
- The review, for
get_review_comments: the comments on lines of the diff, with their file and line. Bitbucket gives no diff hunk, and a review has no text of its own. - The checks, for
get_check_runs: the commit’s build statuses with their descriptions, and, for each failed Bitbucket Pipelines run of the commit, each failed step with the end of its log. A failed run shows twice: as its build status, and as its failed steps. - Which pull request a failed build is about: the branch the build status names (
refname), among the open pull requests kōjō recorded. - The commit: written through the
srcendpoint with the branch’s head as its parent. Bitbucket refuses the commit when the branch moved in between, so nothing anyone pushed is overwritten. - A person’s pull request (commits on a person’s pull request): Bitbucket Cloud’s pull requests have no labels, so only the author’s own mention commits to their branch, and a failed build never starts a round on a person’s pull request. A pull request from another repository (a fork) is never written to.
Merging
Under the auto_merge merge policy, the methods map to Bitbucket’s merge strategies: merge to merge_commit, squash to squash, rebase to rebase_fast_forward. The destination branch must allow the strategy. A draft is marked ready first. A merge that Bitbucket runs in the background, or that the branch’s merge queue takes, is waited for up to two minutes; one still pending then is reported as not merged, and the queue may land it later.
Bitbucket’s merge call cannot name the commit that was checked. kōjō reads the pull request’s head right before merging and does not merge when it is not that commit, but a push in the moment between the read and the merge is merged with it. kōjō then logs an error.
Branch protection
A repository is enabled only when its main branch is protected. On Bitbucket that is any branch restriction that applies to the branch, by name, by pattern or by branch type: a branch permission (who can write or merge, no history rewrite, no deletion) or a merge check. Merge checks block a merge only where they are enforced, a Premium feature; elsewhere Bitbucket warns about an unmet check and merges anyway, so kojo doctor counts required approvals and builds only where they are enforced. Bitbucket counts passing builds rather than naming them.
Clone credentials
Not short-lived. Bitbucket has no installation token. For clones, kōjō hands the proxy the configured API token itself, for
bitbucket.org(with the user namex-bitbucket-api-token-auth) and forapi.bitbucket.org. The token reaches every repository the bot can, and it can write.
As with GitLab, the token stays at the proxy. On bitbucket.org kojo-proxy sets it only on git’s fetch (GET …/info/refs?service=git-upload-pack and POST …/git-upload-pack), outside the API it also serves there (/api/2.0, /!api). On api.bitbucket.org, which serves only the API and which a sandbox reaches only when a kit names it, it is set on reads alone: POST /2.0/repositories/{workspace}/{slug} creates a repository, whatever the slug. A sandbox cannot use it to push or to call a writing API.
With sbx. Docker Sandboxes’ own proxy sets the token, and the
sbxdriver adds deny rules that refuse a push or a writing API call with a403(see Read-only credentials).
Limits
- Bitbucket names a pull request’s commits by abbreviated hashes. kōjō expands each to the full hash, one request per commit it has not seen before; the list of pull requests expands the base and the merge commit only where it needs them (evals from history).
- Requests to repository data are rate limited per account, 1,000 an hour unless the workspace’s plan scales the limit.
- Bitbucket keeps no merge time: a merged pull request’s merge time is its last update, which is later than the merge when someone commented after it.
- A push payload names no files: the files a push changed are unknown.
- Mentions inside quoted text or code blocks count as mentions.