Bitbucket
Orbit builds and deploys from Bitbucket Cloud, with deploy on push and pull request previews, the same way it does from GitHub. Bitbucket Data Center is not supported.
Connecting Bitbucket
In Settings → Integrations → Connect Bitbucket, or when you pick Bitbucket in a new project, give Orbit:
- The workspace ID, as in
https://bitbucket.org/<workspace>/. - An access token from that workspace: a workspace access token reaches all its repositories, a project access token those of one project, and a repository access token a single repository. Give it these permissions:
- Repositories: Read, to list and read the repositories and clone them for builds;
- Webhooks: Read and write, to add the webhooks that deploy on push;
- Pull requests: Read, optional, so pull requests reach Orbit and get previews.
A token without the first two is refused with a message that names the missing scope. Without the third, pushes deploy but pull requests get no preview; Settings says so.
- Where the token lives: it is sealed in Orbit's secret store, never shown again and never written to the logs. It travels with
orbit backup. - Each workspace in Orbit connects its own Bitbucket workspace.
Choosing a repository
In a new project, choose Git repository, then Bitbucket. Orbit lists the repositories the token can read, most recently updated first. Pick one and a branch, and Orbit reads the branch through Bitbucket's API to detect how to build and run it, as it does for GitHub. The Compose import also reads a compose.yaml from a Bitbucket repository.
Builds clone with git. Bitbucket does not let access tokens download a commit's archive, so Orbit fetches the commit with git on the main server, authenticated with the token. Ubuntu Server ships git; on a server without it, install it (apt-get install git) before deploying from Bitbucket, or the build fails saying so.
Deploying on push
When an application is created from a Bitbucket repository, Orbit adds a webhook to that repository. It sends pushes, and pull requests when the token can read them, to https://orbit.<server-ip-with-dashes>.sslip.io/bitbucket/webhook/<workspace>, signed with a secret only your server knows (X-Hub-Signature).
- A delivery without a signature, or with a wrong one, is refused.
- A push to an application's branch deploys that commit when Deploy automatically is on in the application's settings.
- The same delivery sent twice deploys once.
- Settings → Integrations lists each repository's webhook, or why it could not be added.
Pull request previews
Previews follow the same rules as on GitHub: turn them on in a project's Previews, and every pull request opened from a branch of a repository that the source environment builds gets a preview, redeployed on every push and removed with its data when the pull request is merged or declined.
- Forks: pull requests from forks never get a preview, so code from outside the repository never runs on your servers.
Disconnecting
Disconnect Bitbucket removes the webhooks Orbit added and forgets the token. Applications keep their source and can be connected again later, but they stop deploying on push.