> ## Documentation Index
> Fetch the complete documentation index at: https://ona.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Bitbucket Cloud

> Configure Bitbucket Cloud as a source control provider for your Ona environments.

Source control integrations can be configured for both [Self-Hosted Runners](/ona/runners/aws/overview) and [Ona Cloud](/ona/runners/ona-cloud). You can set up a Bitbucket integration during runner creation or in the runner settings. Self-hosted Bitbucket instances (Bitbucket Server / Data Center) are currently not supported.

## Configuring Bitbucket Access

If Bitbucket is already set up on your runner, skip to [Authorizing Bitbucket Access](#authorizing-bitbucket-access).

### Ona Cloud

[Ona Cloud](/ona/runners/ona-cloud) provides built-in Bitbucket Cloud integration with no configuration required.

[Authorize access to Bitbucket](#authorizing-bitbucket-access) when creating your first environment.

### Self-Hosted Runners

For self-hosted runners (like AWS), Bitbucket integration is configured during runner creation or in the runner settings.

We are currently supporting OAuth for authorizing Bitbucket access. Support for Personal Access Tokens (PATs) is planned.

#### Using OAuth

1. Go to **Settings → Runners** and select the runner you want to configure.
2. In the **Configure repository access** section, click **Select** next to **Bitbucket**. If other providers are already configured, click **Add a new provider** first.
3. Toggle **Enable OAuth**.
4. Follow the instructions in [Bitbucket's docs](https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/) to create an OAuth app.
   * The app name can be any name you like
   * You can get the callback URL from the configuration dialog
   * Select the required scopes:
     * *account* so that the git author name and email can be set in the environment
     * *repository* so that the repository can be cloned and the context URL can be parsed
     * *repository:write* so that changes can be pushed from the environment
     * *pullrequest* so that an environment can be started from a pull request
5. Enter the **Client ID** and **Client Secret** from the OAuth app. Bitbucket calls these *Key* and *Secret*. The client secret is encrypted with the runner's public key, so only the runner can read it.
6. Click **Save & Test**.

## Authorizing Bitbucket Access

### Using OAuth

1. When creating your first environment, you will be asked to authorize the new application. To use OAuth press the *Connect* button. A new window will open that directs you to Bitbucket to authorize the OAuth app. The requested scopes are *account*, *repository*, *repository:write*, and *pullrequest*.

   * The *account* scope is required so that the git author name and email can be set in the environment
   * The *repository* scope is required so that the repository can be cloned and the context URL can be parsed
   * The *repository:write* scope is required so that changes can be pushed from the environment
   * The *pullrequest* scope is required so that an environment can be started from a pull request

2. After you have authorized, you can close the window. After a few seconds you should get a confirmation that Bitbucket is now connected.
