Bitbucket manual setup
The manual setup is the alternative to installing Kadmo for Bitbucket; the app never asks for, receives or stores an API token. It is Kadmo's own connection to Bitbucket Cloud: an admin of your Kadmo account pastes an Atlassian account's e-mail and an API token on Kadmo's Bitbucket card, and Kadmo and your agents work in the repositories that account can reach, under its name. This page covers when the manual setup serves a repository, the token and its scopes, saving and replacing it, what agents get, pull requests and events, disconnecting and what Kadmo keeps. What the app does is on Bitbucket.
When the manual setup serves a repository
Open Integrations → Git Hosting → Bitbucket. Where the dialog offers Install Kadmo for Bitbucket, the manual setup is below it, under Manual setup. Where it offers no install and no workspace is connected, the dialog says Kadmo for Bitbucket cannot be installed from here: set Bitbucket up by hand under Manual setup., the manual setup's form follows under the head Manual setup, and the card reads Manual setup.
For each repository Kadmo asks which way serves its workspace, and the agents, the merge gate and a skill pack on Bitbucket all get the same answer:
| The workspace | The answer |
|---|---|
| Connected through the app, its token current | The app |
| Connected through the app, its token not renewed | The manual setup, where one is saved; otherwise nothing, with the not-renewed sentence |
| The app removed from it | The manual setup, where one is saved; otherwise nothing: Kadmo for Bitbucket is no longer installed on the workspace … |
| Not connected through the app | The manual setup, where one is saved; otherwise nothing: Bitbucket is not connected for the workspace … |
Create the API token
- Go to id.atlassian.com/manage-profile/security/api-tokens, signed in as the Atlassian account Kadmo should act as, and choose Create API token with scopes. Give it a name and an expiry date, then pick Bitbucket.
- Tick the nine scopes below, create the token and copy it: Atlassian shows it once.
| Scope | Why |
|---|---|
read:user:bitbucket | Save and Test read the account the token belongs to |
read:workspace:bitbucket | Read the workspace a repository belongs to |
read:repository:bitbucket | Clone and fetch: agents and a skill pack on Bitbucket |
read:pullrequest:bitbucket | Read a pull request: the merge gate, and agents working on one |
write:repository:bitbucket | Push: the agents' branches, and a skill-pack edit |
write:pullrequest:bitbucket | Open a pull request and comment on it: agents, and a skill-pack edit in pull request mode |
read:webhook:bitbucket | Check that each attached repository's webhook is still there |
write:webhook:bitbucket | Add the webhook through which a repository's pull requests start rules and the review |
delete:webhook:bitbucket | Remove that webhook when the repository is detached, the app takes its workspace over, or the manual setup is disconnected |
Bitbucket does not say which scopes a token carries, so Save and Test prove the account only; a missing scope shows up when the work that needs it fails, with Bitbucket's own error.
Save it on the card
- In the Bitbucket dialog, open Manual setup, enter the Atlassian account e-mail of that account and paste the API token.
- Press Save. Kadmo reads the account with the token first and stores the token, encrypted, only when Bitbucket accepts it; the card then shows the account's name. Test reads the account again with the stored token at any time (Valid ✓ — …).
Everything done with the token carries its person's name and reaches what that person can reach in Bitbucket, so an Atlassian account made for Kadmo keeps people's own accounts out of it. To replace the token, enter the e-mail and a new token in the same fields and save: the new one replaces the old. Atlassian ends a token on its expiry date, so replace it before then.
App passwords. Bitbucket no longer accepts app passwords. A card that still holds one reads red with Bitbucket no longer accepts app passwords: reconnect with an API token, and Kadmo makes no call with it until you save an API token in its place.
Repositories and agents
- Repositories. On a workspace's Code & files tab, Add project takes the repository's address, pasted (Git projects); the list of a workspace's repositories to pick from comes with the app.
- Agents. They fetch the token from Kadmo at the moment they use it, for the repositories of the workspaces they work in, and work under its person's name (What agents get). An agent that already has an API token of your own in its environment (
BITBUCKET_API_TOKEN) keeps it: Kadmo never writes or removes it. - The merge gate and a skill pack use the token where it serves the workspace (The merge gate and your skill pack). A stored app password reads as cannot verify, and is never counted as merged.
Pull requests and events
Where the manual setup serves a repository's workspace, Kadmo adds a webhook to each attached repository with the API token, so its pull requests, their comments, pushes and build results reach Kadmo and start the same rules and review as through the app (What starts work). The first webhook adds the same two rules a connect of the app adds, once per account (The two rules a connect adds).
- When. On Save and Test, when a repository is attached, and every 15 minutes. Detaching the repository, or the app taking its workspace over, removes the webhook; disconnecting the manual setup removes every one first.
- Who must make the token. An admin of each repository: Bitbucket lets only an admin add a webhook. The token needs the three webhook scopes above.
- What the card says. Below the workspaces (or below the form, when the manual setup is the card's only way), each attached repository's line reads its pull requests start rules and the review, with the age of its last event, or in red why its webhook could not be added: The API token may not add a webhook to … (a missing scope, or not an admin), that Bitbucket no longer accepts the API token, or that the repository already holds as many webhooks as Bitbucket allows. Before a webhook exists the line says when it comes, or why none can be added yet: its webhook is made once the connection is tested (press Test), or that the server has no public https address Bitbucket can post to. Such a repository still works for agents: they push and open pull requests.
- What starts nothing. Anything the token's own account does: on this way your agents act as that account, so its pull requests and comments are theirs. Make the token with an Atlassian account kept for Kadmo, so people's own pull requests get their review.
- What is written back. The status Kadmo review, a run's comment and the reply to a mention, as the token's account.
- Where the app serves the workspace, it alone starts work there, and no webhook is added.
- The address. Bitbucket must reach Kadmo: a webhook goes to Kadmo's public address, so the Desktop edition adds none.
- Only with the app. Send to Kadmo and the run's card on the pull request page. Bitbucket sends no update when another pull request is merged into a pull request's source branch, so a rule on PR updated does not hear it on either way.
Disconnect
Disconnect manual setup in the footer (Disconnect while no workspace is connected through the app) removes the webhooks the manual setup added, then the stored API token: Disconnect the manual setup? Its API token is removed, and repositories outside the connected workspaces lose access. (with no workspace connected, Disconnect Bitbucket? The manual setup's API token is removed and repository reads stop.). The workspaces connected through the app and the projects that point at Bitbucket stay. Revoke the token at Atlassian too.
What Kadmo keeps
| Read from Bitbucket | Kept | |
|---|---|---|
| The API token | The profile of the token's account: its id, its display name and its picture | The token and the e-mail, encrypted, and the profile; per attached repository its webhook's id, its secret (encrypted), its state and its last event, and the head commit of each open pull request |
| Events | Each pull request, comment, reviewer, build and repository event of each attached repository, where the event itself carries the names, the description and a comment's text. For a rule that would act: the repository, the pull request, the comment's text and author | The work a rule starts, with the account's other work |
Kadmo's privacy policy says how Kadmo handles personal data.
Troubleshooting
| Symptom | Cause and fix |
|---|---|
| Save or Test says Bitbucket rejected the e-mail and API token | The e-mail is not the one of the Atlassian account that made the token, or the token was revoked or has ended. |
| Save or Test says The API token cannot read your Bitbucket user: … | The token lacks read:user:bitbucket. Make a new token with the nine scopes. |
| The card reads Bitbucket no longer accepts app passwords: reconnect with an API token | The card holds an old app password. Save an API token in its place. |
| A repository's line reads The API token may not add a webhook to … | Make a new token with the three webhook scopes, as an admin of the repository, and save it; Test tries again at once. |
| Opening a pull request starts no review | The rule needs the repository's webhook, a person as the author (not the token's own account), a repository a workspace has, and no fork (Pull requests and events). Read the rule's log on Automations: no_workspace means no workspace has the repository. |
| An agent reports … is not attached to a workspace this agent works in, so no token is handed out for it. | Add the repository as a project to a workspace the agent works in. |