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

# Bitbucket Data Center

> Learn how to integrate CodeRabbit with your self-hosted Bitbucket Data Center instance for AI-powered code reviews on pull requests.

<Info>
  For a hands-on tutorial with CodeRabbit performing code reviews on a live repository, see [Quickstart](/getting-started/quickstart).
</Info>

CodeRabbit integrates with Bitbucket Data Center to bring AI-powered code reviews to your self-hosted Bitbucket instance:

* **Automated code reviews** for newly created pull requests
* **Intelligent comments and suggestions** displayed directly on pull requests
* **Real-time bot interaction** for immediate feedback and assistance
* **Seamless webhook integration** for continuous monitoring

This guide walks you through connecting your Bitbucket Data Center instance to CodeRabbit.

<Info>
  To interact with CodeRabbit in pull request comments, use `@coderabbitai` — or the username of the bot user you create below, if it differs.
</Info>

## Prerequisites

Before starting, you need to set up the following in your Bitbucket Data Center instance:

<Steps>
  <Step title="Create a bot user">
    Create a dedicated Bitbucket user for CodeRabbit (e.g., "CodeRabbit"). This user will post code review comments on pull requests.

    * Add the bot user to each project where you want CodeRabbit to review pull requests
    * Grant the bot user **write** permissions on the relevant repositories
  </Step>

  <Step title="Generate an HTTP Access Token for the bot user">
    Generate an HTTP Access Token for the bot user:

    1. Log in as the bot user
    2. Navigate to **Manage Account** and select **HTTP Access Tokens**
    3. Create a new token with **repository write** permissions

    <Warning>
      Save the token securely. It will only be shown once.
    </Warning>
  </Step>

  <Step title="Create an OAuth consumer">
    Create an OAuth consumer in your Bitbucket Data Center administration:

    1. Navigate to **Administration** and then **Application Links**
    2. Create a new **External application** with an **Incoming link**
    3. Set the **Redirect URL** to: `https://app.coderabbit.ai/login`
    4. Grant the following permissions:
       * **Repository Read**
       * **Repository Write**
       * **Project Read**
    5. Note the **Client ID** and **Client Secret**
  </Step>
</Steps>

## Connect to CodeRabbit

<Steps>
  <Step title="Navigate to the CodeRabbit login page">
    Go to the [CodeRabbit login page](https://app.coderabbit.ai/login?free-trial) and select **Bitbucket Data Center**.
  </Step>

  <Step title="Enter your Bitbucket Data Center URL">
    Enter the URL of your Bitbucket Data Center instance (e.g., `https://bitbucket.company.com`) and click **Submit**.

    If your instance is already registered, you will be redirected to the OAuth authorization flow. Otherwise, you will be prompted to provide your credentials.
  </Step>

  <Step title="Provide credentials">
    If this is the first time connecting your instance, provide:

    * **Bot Token**: The HTTP Access Token you generated for the bot user
    * **Client ID**: The OAuth consumer Client ID
    * **Client Secret**: The OAuth consumer Client Secret

    Click **Validate token** to verify the bot token before proceeding.
  </Step>

  <Step title="Authorize CodeRabbit">
    You will be redirected to your Bitbucket Data Center instance to authorize CodeRabbit. Review the requested permissions and click **Allow**.
  </Step>
</Steps>

## Install CodeRabbit on your repositories

After logging in, the onboarding wizard guides you through selecting projects and repositories.

<Steps>
  <Step title="Select a project">
    Choose the Bitbucket Data Center project containing the repositories you want CodeRabbit to review.
  </Step>

  <Step title="Select repositories">
    * Browse or search for repositories within the selected project
    * Select the repositories where you want to enable AI code reviews
    * Click **Install** to complete the setup
  </Step>
</Steps>

<Info>
  CodeRabbit will automatically configure webhooks for the selected repositories. Once installed, CodeRabbit begins reviewing new pull requests immediately.
</Info>

## Configure network access

If your Bitbucket Data Center instance requires IP allowlisting, add these CodeRabbit IP addresses:

```text IPs to allow list theme={null}
35.222.179.152/32, 34.170.211.100/32, 136.113.208.247/32
```

## Manage credentials

You can update the bot user's HTTP Access Token at any time:

1. Navigate to **Organization Settings** in the CodeRabbit app
2. Select the **Bitbucket DC User** tab
3. Enter the new HTTP Access Token
4. Save your changes

## Manual webhook installation

If you install repositories from the CodeRabbit app, CodeRabbit configures the webhook automatically. Use this flow only when you need to install the webhook manually or rotate the shared webhook secret.

The **Webhook Secret** page is available to Bitbucket Data Center organizations with organization settings access.

<Steps>
  <Step title="Open Webhook Secret settings">
    In the CodeRabbit app, open **Account** and select **Webhook Secret** from the sidebar.
  </Step>

  <Step title="Copy the webhook URL">
    Use the **Webhook URL** field on that page to copy the exact endpoint that your Bitbucket Data Center project or repository webhook should call.
  </Step>

  <Step title="Save or change the webhook secret">
    Enter the secret that Bitbucket Data Center should send with webhook deliveries and save it in CodeRabbit.
  </Step>

  <Step title="Configure the Bitbucket Data Center webhook">
    When creating or editing the webhook in Bitbucket Data Center, use the copied webhook URL and enable these pull request events:

    * **Opened**
    * **Modified**
    * **Comment Added**
  </Step>
</Steps>

<Info>
  If you change an existing webhook secret, CodeRabbit attempts to update existing CodeRabbit-managed Bitbucket Data Center webhooks across installed repositories automatically and reports how many were updated, skipped, or failed. If a webhook was created manually, or if an automatic refresh fails, update the secret directly in Bitbucket Data Center.
</Info>

Manually configured Bitbucket Data Center webhooks are validated with the per-repository secret first, then the self-hosted instance-level secret when no per-repository secret is available. For self-hosted deployments, keep `BITBUCKET_SERVER_WEBHOOK_SECRET` aligned with the secret configured in CodeRabbit; see the [Bitbucket Data Center self-hosted `.env` file](/self-hosted/bitbucket#prepare-a-env-file).

## Troubleshooting

<AccordionGroup>
  <Accordion title="Bot token validation fails">
    * Verify the HTTP Access Token has the correct permissions (repository write)
    * Ensure the bot user account is active and not locked
    * Check that your Bitbucket Data Center URL is correct and accessible from the internet
  </Accordion>

  <Accordion title="OAuth authorization fails">
    * Verify the Client ID and Client Secret match the OAuth consumer configured in Bitbucket DC
    * Ensure the callback URL is set to `https://app.coderabbit.ai/login`
    * Check that the OAuth consumer has the required permissions
  </Accordion>

  <Accordion title="Webhooks not working">
    * Ensure your Bitbucket Data Center instance can reach CodeRabbit's servers
    * Check webhook configurations in your repository settings
    * Verify the bot user has write access to the repositories
  </Accordion>

  <Accordion title="Webhook secret mismatch">
    * Confirm the webhook secret in Bitbucket Data Center matches the value saved on CodeRabbit's **Webhook Secret** page
    * Update manually created webhooks directly in Bitbucket Data Center after rotating the secret
    * Review skipped or failed refreshes reported by CodeRabbit and update those repository webhooks directly
    * For self-hosted deployments, confirm `BITBUCKET_SERVER_WEBHOOK_SECRET` matches the secret configured in CodeRabbit
  </Accordion>

  <Accordion title="Reviews not posting">
    * Confirm the bot user is added to the project with write permissions
    * Verify the HTTP Access Token has not expired
    * Check that webhooks are properly configured and active
  </Accordion>
</AccordionGroup>

<Info>
  For additional support, visit the [support page](/support).
</Info>

## What's next

<CardGroup cols={1}>
  <Card title="Configure CodeRabbit" icon="settings" href="/getting-started/yaml-configuration" horizontal="true">
    Customize review behavior, language settings, and rules for your repositories.
  </Card>

  <Card title="Code Review Overview" icon="search" href="/guides/code-review-overview" horizontal="true">
    Learn how CodeRabbit reviews your pull requests and provides actionable feedback.
  </Card>

  <Card title="Get Support" icon="life-buoy" href="/support" horizontal="true">
    Reach out to the CodeRabbit team for help with setup or integration issues.
  </Card>
</CardGroup>
