# Setting up Bitbucket Cloud integration at global level

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.&#x20;

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

### Prerequisites

You’ve set a SonarQube Community Build base URL in SonarQube Community Build: see [server-base-url](https://docs.sonarsource.com/sonarqube-community-build/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 import repositories and display 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-community-build/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 "Bitbucker 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. In the SonarQube UI, 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**.

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

4. Specify the following settings:
   * **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.

### Related pages

[import-repos](https://docs.sonarsource.com/sonarqube-community-build/devops-platform-integration/bitbucket-integration/bitbucket-cloud-integration/import-repos "mention")\
[bitbucket-pipelines](https://docs.sonarsource.com/sonarqube-community-build/devops-platform-integration/bitbucket-integration/bitbucket-cloud-integration/bitbucket-pipelines "mention")\
[troubleshooting](https://docs.sonarsource.com/sonarqube-community-build/devops-platform-integration/bitbucket-integration/bitbucket-cloud-integration/troubleshooting "mention")
