# Binding to Bitbucket Cloud

This section explains how to set up Bitbucket Cloud and SonarQube to allow users to import Bitbucket Cloud repositories. To perform this setup, you need the global Administer System permission in SonarQube.

For more information about the Azure DevOps integration solution, see [Broken link](https://docs.sonarsource.com/sonarqube-server/instance-administration/devops-platforms/broken-reference "mention").

{% hint style="info" %}
To set up Bitbucket Cloud authentication in your SonarQube Server instance, see [bitbucket-cloud](https://docs.sonarsource.com/sonarqube-server/instance-administration/authentication/bitbucket-cloud "mention").
{% endhint %}

## Prerequisites

You’ve set a SonarQube Server base URL in SonarQube Server: see [server-base-url](https://docs.sonarsource.com/sonarqube-server/instance-administration/server-base-url "mention").

## Step 1: Create your OAuth consumer

SonarQube uses a dedicated[ OAuth consumer](https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/) to report your quality gate status on pull requests. When you create your OAuth consumer, Bitbucket automatically creates an OAuth key and an OAuth secret that you will need in Step 2.

Proceed as follows:

1. Create the OAuth consumer in your Bitbucket Cloud workspace settings and specify the following:
   * **Name**: The name of your OAuth consumer.
   * **Callback URL**: Bitbucket Cloud requires this field, but it’s not used by SonarQube so you can use any URL.
   * **This is a private consumer**: Your OAuth consumer needs to be private. Make sure this check box is selected.
   * **Permissions**: Grant Read access for the **Pull requests** permission.
2. Retrieve the created OAuth secret and key in your Bitbucket Cloud workspace settings under **OAuth consumers**. If you want to enter the secret in SonarQube in encrypted format, you can encrypt this secret.

See [encrypting-settings](https://docs.sonarsource.com/sonarqube-server/instance-administration/security/encrypting-settings "mention") for more information about settings encryption.

## Step 2: Create a Bitbucket Cloud configuration record

This integration is performed through a "Bitbucket Cloud Configuration" record, which is used in SonarQube to access the Bitbucket Cloud instance.

{% hint style="info" %}
Starting in SonarQube Server's[ Enterprise edition](https://www.sonarsource.com/plans-and-pricing/enterprise/), you can integrate SonarQube with multiple Bitbucket Cloud instances, each instance being accessed with a different Bitbucket Configuration.
{% endhint %}

To set up a Bitbucket Configuration in SonarQube:

1. Go to **Administration** > **Configuration** > **General Settings** > **DevOps Platform Integrations**.
2. Select the **Bitbucket** tab and click **Create configuration**. The **Create a configuration** dialog opens.
3. Select **Bitbucket Cloud**.

<div align="left"><figure><img src="broken-reference" alt="Select Bitbucket Cloud in the Create a configuration dialog." width="440"><figcaption></figcaption></figure></div>

4. Specify the following settings:
   * **Configuration Name** (Enterprise and Data Center Edition only): The name used to identify your Bitbucket Cloud configuration at the project level. Use something succinct and easily recognizable.
   * **Workspace ID**: The workspace ID is part of your bitbucket cloud URL `https://bitbucket.org/<workspace-id>/<repository-slug>`
   * **OAuth Key**: The key you created in Step 1.
   * **OAuth Secret**: The secret you created in Step 1.

## Troubleshooting

#### API request limit exceeded <a href="#api-request-limit-exceeded" id="api-request-limit-exceeded"></a>

If your Bitbucket Cloud API calls fail with HTTP 429 code and "[Rate limit for this resource has been exceeded](https://support.atlassian.com/bitbucket-cloud/docs/api-request-limits/)" error, try to use a dedicated Bitbucket user for SonarQube Server integration.

## Related pages

* [import-repos](https://docs.sonarsource.com/sonarqube-server/project-administration/creating-project/bitbucket-cloud/import-repos "mention")
* [configure-binding](https://docs.sonarsource.com/sonarqube-server/project-administration/creating-project/bitbucket-cloud/configure-binding "mention")
* [bitbucket-pipelines](https://docs.sonarsource.com/sonarqube-server/analyzing-source-code/ci-integration/bitbucket-pipelines "mention")
* [Broken link](https://docs.sonarsource.com/sonarqube-server/instance-administration/devops-platforms/broken-reference "mention")
