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

# Bitbucket Data Center

> Connect your self-hosted repositories, add webhooks, and receive your first pull request review.

> [!NOTE]
>
> For a workspace at `bitbucket.org`, use the [Bitbucket Cloud setup guide](https://docs.codeant.ai/setup/bitbucket.md).

## Before you begin

* A company email address you can use to sign in to CodeAnt AI and receive a verification code. Public email addresses such as Gmail or Yahoo are not supported by this sign-in flow.
* A Bitbucket Data Center account with access to the projects and repositories you want reviewed and permission to create an HTTP access token.
* A project administrator who can create project webhooks. See [Atlassian's webhook requirements](https://confluence.atlassian.com/bitbucketserver/manage-webhooks-938025878.html).
* Your Bitbucket base URL and a repository where you can open a pull request.

CodeAnt must be able to reach your Bitbucket instance to fetch changes and post comments. Your instance must also be able to deliver webhook events to CodeAnt. If the instance is private, [contact CodeAnt support](mailto:support@codeant.ai) to confirm connectivity before setup.

## Connect your instance

**1. Create an HTTP access token**

In Bitbucket Data Center, open your profile menu and select **Manage account** → **HTTP access tokens** → **Create token**.

| Field | Value |
| - | - |
| Token name | `CodeAnt AI` |
| Expiry | A date permitted by your organization's policy; plan to replace the token before then |
| Project permissions | **Project read** |
| Repository permissions | **Repository write** |

Select **Create** and copy the token before closing the page. The token's account must have access to the repositories you want reviewed. See [Atlassian's HTTP access token guide](https://confluence.atlassian.com/bitbucketserver/http-access-tokens-939515499.html) for token permissions and expiry options.

**2. Sign in to CodeAnt AI**

Open the [CodeAnt AI dashboard](https://app.codeant.ai) and select **Self-Hosted** → **Sign in with SSO**. Enter your company email address, then enter the verification code sent to your inbox.

After sign-in, select **Change Provider** and choose **Bitbucket**.

**3. Save your Bitbucket details**

Enter these values in the setup form:

| Field | Value |
| - | - |
| Domain | Your company domain, such as `example.com` |
| Bitbucket Base URL | Your instance URL, such as `https://bitbucket.example.com` |
| Access token | The HTTP access token you created above |

Select **Validate & Submit**. CodeAnt fetches the projects and repositories available to the token's account.

Confirm that a repository you expect appears in CodeAnt. Continue with the webhooks below to enable automatic reviews.

## Add both project webhooks

In Bitbucket Data Center, open the project containing the repositories you want reviewed. Go to **Project settings** → **Webhooks**. Create both webhooks below for that project.

**1. Send pull request events to CodeAnt**

Select **Create webhook** and enter:

| Field | Value |
| - | - |
| Name | `CodeAnt PR Review` |
| URL | `https://api.codeant.ai/pr/bitbucket/pr_review/processPullRequestBitbucket` |
| Status | **Active** |
| Skip certificate verification | Unchecked |
| Authentication | None |

Under **Pull request**, select **Opened**, **Modified**, and **Source branch updated**. Select **Save**.

![Bitbucket Data Center webhook with Opened, Modified, and Source branch updated events selected](https://mintcdn.com/codeantai/5hlXFJYaiG5gl5rY/images/setup/bitbucket/data_center/webhooks/pr_review_webhook_events.png?fit=max\&auto=format\&n=5hlXFJYaiG5gl5rY\&q=85\&s=743e73ebf458a2170357c4d593ab235c)

**2. Send pull request comments to CodeAnt**

Select **Create webhook** again and enter:

| Field | Value |
| - | - |
| Name | `CodeAnt PR Comment` |
| URL | `https://api.codeant.ai/pr/bitbucket/handle_comment/handleBitBucketPRComment` |
| Status | **Active** |
| Skip certificate verification | Unchecked |
| Authentication | None |

Under **Pull request**, select **Comment added**. Select **Save**. This webhook delivers review commands and questions posted on PRs.

Confirm that **CodeAnt PR Review** and **CodeAnt PR Comment** are listed as active. Repeat this setup for any other projects you want reviewed.

## Get your first review

Open a pull request in a connected repository in the configured project. CodeAnt AI reviews the changes and posts feedback directly on the PR. When it finds an issue, its comment explains the problem, severity, and suggested fix. See [how to read a review comment](https://docs.codeant.ai/pull_request/features/code_review.md).

To review an existing PR or rerun a review, post:

```text theme={"theme":"css-variables"}
@codeant-ai: review
```

The **Comment added** webhook must be active for this command to reach CodeAnt.

## Troubleshooting

> [accordion] I have not received my sign-in code
>
> Confirm your company email address and check spam, junk, and quarantine folders. If the code is still missing, ask your email administrator to check delivery or [contact CodeAnt support](mailto:support@codeant.ai).

> [accordion] Validation fails or my repository is missing
>
> Check the base URL, company domain, and token value. Confirm that the token has not expired or been revoked and that its account can access the project and repository. If your instance is private, confirm that CodeAnt can reach it; browser access from your machine does not verify this network path.

> [accordion] My pull request has not received a review
>
> Confirm that the repository appears in CodeAnt and that both webhooks are active in the PR's project. Compare their URLs and events with the tables above, then post `@codeant-ai: review`. If it still fails, [contact CodeAnt support](mailto:support@codeant.ai) with the instance URL, project, and PR URL. Do not include the HTTP access token.

> [accordion] Review commands do not receive a response
>
> Check that **CodeAnt PR Comment** uses the comments endpoint and has **Comment added** selected. The review webhook alone does not deliver PR comments.

## Next steps

> [card] [Customize your reviews](https://docs.codeant.ai/pull_request/customize/rules.md)
>
> Add review rules for your team's coding standards.

> [card] [Configure repository scans](https://docs.codeant.ai/repositories/analysis_configuration.md)
>
> Choose which analyses run and which files they include.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.