Ployter

Connect Bitbucket

How to connect Bitbucket Cloud by signing in, in a few clicks, or with an Atlassian API token, for private repositories, deploy on every push and pull request previews.

The panel uses the Bitbucket connection to clone private repositories, deploy on every push and comment on pull requests with the preview address. Public repositories work without a connection for manual deploys.

Two ways to connect

Bitbucket login (recommended) API token
How it connects Click Connect with Bitbucket, authorize and come back connected Create a token in your Atlassian account and paste it in the panel
Repositories The ones in your account's workspaces The ones the token can see
Validity The panel renews access by itself The token expires when you chose
Pull request comment Shows up as your account Shows up as the token's account

Either way, deploy on every push and previews use a webhook on each repository, created by the panel.

Bitbucket page in the panel with one login connection and one token connection
Bitbucket page in the panel with one login connection and one token connection

Connect by signing in

You need the Manage GitHub, GitLab and Bitbucket connections permission in the panel. By default, owners and admins have it.

  1. In the panel, open Integrations → Bitbucket and click Connect with Bitbucket.
  2. Sign in to Bitbucket, if you aren't signed in yet.
  3. Bitbucket shows the permissions Ployter asks for. Click Grant access.
  4. You come back to the panel and the connection shows up in the list with the Login badge and the account name.

Bitbucket access lasts 2 hours, and the panel renews it by itself when needed. If the connection goes unused for 3 months, Bitbucket asks for the login again: click Connect with Bitbucket and the same connection is updated.

To revoke Ployter's access for good, revoke it in Personal settings → App authorizations in Bitbucket.

Note

A login connection isn't copied to other teams by Import from another team. In each team, click Connect with Bitbucket.

Connect with an API token

Bitbucket no longer accepts app passwords. Use an Atlassian account API token instead:

  1. Open id.atlassian.com, under Account settings → Security → API tokens, and click Create API token with scopes.
  2. Pick Bitbucket and check the scopes read:user:bitbucket, read:repository:bitbucket, read:pullrequest:bitbucket, write:pullrequest:bitbucket, read:webhook:bitbucket and write:webhook:bitbucket.
  3. In the panel, open Integrations → Bitbucket and click Use a token.
  4. Give it a name, paste the token and click Save. The panel checks the token with Bitbucket before saving and stores it encrypted.

New Bitbucket token modal
New Bitbucket token modal

For the panel to create the webhook, the account must be a repository admin. Without that (or without the webhook scopes), manual deploys work, but deploy on every push isn't turned on by itself.

To replace an expired token, click the connection's pencil and paste the new one.

Use the connection in a service

  1. In the project, click New service and pick Git repository.
  2. Under Repository, the list shows each connection's repositories, grouped by account. Pick the repository: the main branch is already selected.
  3. Check the branch and the folder (in a monorepo) and click Create service.

Repository list with GitHub, GitLab and Bitbucket connections
Repository list with GitHub, GitLab and Bitbucket connections

For a public repository, use Paste a public repository URL and paste the address (https://bitbucket.org/workspace/repository), without a connection.

Deploy on every push

With Automatic deploy on in the service, the panel creates a webhook on the repository (push and pull requests). Each push to the service's branch deploys that commit. Tag pushes and deleted branches are ignored. The webhook is signed, and the panel rejects calls without the right signature.

The webhook is removed by itself when no service uses the repository with automatic deploy or previews anymore.

Note

Cloning from Bitbucket needs agent v0.26.0 or later on the server. With an older agent, the panel asks you to update it in Servers › Update agent.

Pull request previews

Under the service's Settings → PR previews, each pull request to the service's branch brings up a copy with the PR code, at its own address. The panel comments on the PR with the link and edits the same comment on every push. The preview goes away when the PR is merged or declined.

A draft pull request only gets a preview when it leaves draft. Pull requests from forks don't get a preview, because outside code would run with the service's variables. See Previews.

Remove the connection

In the list, click the connection's trash icon. Services that used it are left without a credential: a private repository stops cloning until you pick another one. Webhooks already created stay in Bitbucket; incoming pushes are ignored.