workbench Docs

Atlassian

Bitbucket

Connect Bitbucket Cloud so an agent can browse repositories, run the full pull-request review loop, and drive Pipelines.

The Bitbucket integration covers a complete review cycle. It can list repos, open a pull request, read its diff, comment inline, approve or request changes, then merge or decline. It also triggers, polls, and stops Bitbucket Pipelines. It can mint a short-lived authenticated clone URL.

At a glance#

Plugin idatlassian-bitbucket
AuthOAuth 2.0 (workspace consumer)
Tools20
Authorization URLhttps://bitbucket.org/site/oauth2/authorize
Token URLhttps://bitbucket.org/site/oauth2/access_token
Proxy basehttps://api.bitbucket.org/2.0

Bitbucket Cloud OAuth is separate from the Atlassian developer console that Jira and Confluence use. You create a "consumer" inside a Bitbucket workspace's own settings.

Set up the OAuth app#

The console steps are Atlassian's UI, not this server's

Menu names, labels, and page URLs below come from Atlassian's console and change without notice. If what you see differs, follow Atlassian's own documentation — the values this server needs (the callback URL and the scopes in the tables below) are unaffected.

Create the consumer#

Go to https://bitbucket.org/<workspace>/workspace/settings/api, or Workspace settings → Apps and featuresOAuth consumersAdd consumer.

Fill in the callback URL#

FieldValue
Nameyour deployment name
Callback URLhttps://<your-workbench-host>/api/auth/plugin/atlassian-bitbucket/callback
This is a private consumerleave unchecked for the normal three-legged flow

Bitbucket allows only one callback URL per consumer. For local development create a second consumer pointing at http://localhost:3000/api/auth/plugin/atlassian-bitbucket/callback.

Tick the permissions#

Check every scope in the table below. The checkboxes nest: selecting repository:write auto-selects repository, and pipeline:write auto-selects pipeline.

Copy the credentials#

Save, then expand the consumer in the list to reveal Key (the client id) and Secret.

Scopes#

ScopeWhat it is for
repositoryRead repositories, files, branches, and commits the user can see
repository:writeWrite repository contents
pullrequest:writeCreate, comment on, approve, merge, and decline pull requests
pipelineRead Pipelines runs
pipeline:writeTrigger and stop Pipelines runs
accountRead account and workspace membership — backs workspace defaulting and user search
Adding `pipeline` and `pipeline:write` forces a reconnect

These two were added after the integration first shipped. Anyone who connected before must disconnect and reconnect. Existing tokens carry the old grant, and the three Pipelines tools return 403 until they do. Adding the scopes to the consumer is not enough on its own.

Server configuration#

bash
ATLASSIAN_BITBUCKET_CLIENT_ID=...
ATLASSIAN_BITBUCKET_CLIENT_SECRET=...

Connect#

Portal: Connections → Connect on the Bitbucket card.

Agent:

text
connect({ integration: "atlassian-bitbucket" })
wait_for_connection({ connectionId })

Tools#

ToolPurpose
bitbucket_list_reposSlim repository rows for a workspace
bitbucket_get_repoOne repo, including its https clone URL and main branch
bitbucket_create_prOpen a pull request from a source branch into a destination branch
bitbucket_list_prsList pull requests by state, paged
bitbucket_get_prOne PR with reviewers, approval status, and open-task counts
bitbucket_get_pr_diffFull diff, or a per-file diffstat summary
bitbucket_list_pr_commentsComments, with { path, line } on inline ones
bitbucket_add_pr_commentPost a general or inline comment
bitbucket_approve_prApprove as the connected user
bitbucket_request_changesMark the PR as changes-requested
bitbucket_merge_prMerge into the destination branch
bitbucket_decline_prClose the PR without merging
bitbucket_list_pr_commitsThe PR's commits as slim rows
bitbucket_get_fileRaw file contents at a specific ref
bitbucket_list_default_reviewersWho Bitbucket will auto-attach to new PRs
bitbucket_search_usersResolve workspace members to UUIDs
bitbucket_trigger_pipelineStart a default or custom pipeline on a ref
bitbucket_get_pipelinePoll one pipeline's state and result
bitbucket_stop_pipelineStop a running pipeline
bitbucket_get_clone_urlMint https://x-token-auth:<token>@bitbucket.org/... for clone, pull, or push

Notes and gotchas#

Naming the PR author as a reviewer makes the create call fail

Bitbucket rejects a pull request whose reviewer list includes its own author, and the failure is not obvious from the error. bitbucket_create_pr filters the author out of reviewers before sending. It also upserts: if an open PR already exists from the same source branch, the call updates that PR instead of creating a second one.

bitbucket_get_file needs a real ref. A branch name or a 40-character SHA works. The literal HEAD does not, on this API.

The token in bitbucket_get_clone_url is the user's live OAuth access token, embedded in a URL. It is short-lived, and the URL dies with it. Mint it immediately before use. Never persist it to a file, a remote, or shell history.

Bitbucket attaches a repository's default reviewers to new pull requests, so a PR can come back with reviewers you did not name. bitbucket_list_default_reviewers shows who those are for a repo.

Bitbucket issues short-lived access tokens and rotates refresh tokens (see Atlassian's Bitbucket OAuth 2.0 documentation for current lifetimes). The server refreshes 30 seconds before expiry and stores each new refresh token automatically, keeping the previous one when the response carries none.