#### Integrations

# Bitbucket

Connect Bitbucket Cloud repositories to [Cloud Agents](/build/agents-window/cloud-agent) and [Bugbot](/build/agents-window/bugbot). Connect Bitbucket Data Center repositories to Bugbot.

> [!NOTE]
>
> [Security Reviewer](/build/agents-window/security-review#source-control-support) and [Vulnerability Scanner](/build/agents-window/vulnerability-remediation#source-control-support) support Bitbucket Cloud repositories. They don't support Bitbucket Data Center repositories.

## Setup

**Bitbucket Cloud**

> [!NOTE]
>
> The Bitbucket Cloud integration is in public beta. It supports repositories on `bitbucket.org`.

Bitbucket Cloud setup has two parts, and each part requires a different role:

* Each developer connects their Bitbucket account so Grok Build can clone repositories, push branches, and open pull requests as that user.
* A Bitbucket workspace admin installs the Cursor app so Bugbot and Cloud Agent status comments appear under that app's name, Cursor. Linking the installed app to your Grok Build team requires a Grok Build team admin with access to the Bitbucket workspace.

### Connect your Bitbucket account

Requires access to the Bitbucket workspace repositories you want to use.

1. Go to [Integrations in the dashboard](https://grok.com/dashboard/integrations)
2. Click **Connect** next to Bitbucket
3. Authorize Grok Build in Bitbucket
4. Return to the dashboard and confirm the integration shows **Connected**

Each person who starts Cloud Agents or opens pull requests from Grok Build should connect their own Bitbucket account.

### Install the Cursor app in Bitbucket

A Bitbucket workspace admin must install the Cursor app for the workspace, which the dashboard calls the Bitbucket app. This gives Grok Build a stable app identity for repository events, Bugbot review comments, inline comments, and status updates.

Steps 1 through 4 require a Bitbucket workspace admin. Steps 5 and 6 require a Grok Build team admin with access to the Bitbucket workspace. If one person handles the full setup, they need both roles.

1. Go to [Integrations in the dashboard](https://grok.com/dashboard/integrations)
2. Find Bitbucket and open the manage menu
3. Click **Install Bitbucket app**
4. Install the app in your Bitbucket workspace
5. In Bitbucket workspace settings, under **Forge Apps**, select **Cursor**, the name the app is listed under in Bitbucket
6. Click **Connect to Cursor** and choose the Grok Build team to link

[Video: Bitbucket setup](https://media.x.ai/v1/docs/agents-window-bitbucket-bitbucket-demo-install-36653474.mp4)

When the workspace is linked, the dashboard shows **Bitbucket app installed** for that Bitbucket workspace.

> [!NOTE]
>
> Bitbucket can take a few minutes to notify Grok Build after app installation. If Grok Build cannot find the workspace right away, wait and try the link step again.

### How Grok Build uses Bitbucket Cloud identities

Grok Build uses different Bitbucket identities for different actions:

| Action | Bitbucket identity |
| --- | --- |
| Bugbot summary comments, inline comments, and build statuses | Cursor app  |
| Cloud Agent progress comments on pull requests | Cursor app |
| Git clone, branch push, commits, and pull request creation | The connected Bitbucket user |

Pull requests opened by Cloud Agents are attributed to the person who started the agent. Bugbot output appears from the Cursor app when the workspace app is installed.

### Permissions

The Bitbucket Cloud integration asks for permissions needed to support Cloud Agents and Bugbot:

| Permission | Purpose |
| --- | --- |
| **Account** | Identify the connected Bitbucket user |
| **Repositories** | List, clone, and read repository content |
| **Pull requests** | Read pull request diffs and metadata |
| **Pull request write** | Create pull requests and post comments |
| **Webhooks** | Receive repository and pull request events |

### Disconnect Bitbucket Cloud

Disconnecting Bitbucket Cloud has two separate effects:

* **Disconnect** removes your personal Bitbucket OAuth connection from Grok Build.
* **Disconnect Bitbucket app** unlinks the Bitbucket workspace from your Grok Build team. The app can remain installed in Bitbucket until a workspace admin removes it there.

To fully stop app events from the workspace, uninstall the Cursor app from Bitbucket workspace settings.

### Switch Bitbucket workspaces

A Grok Build team uses one Bitbucket workspace at a time. To move your team to another workspace, a Grok Build team admin opens the Bitbucket manage menu in [Integrations in the dashboard](https://grok.com/dashboard/integrations) and selects **Switch workspace**. Switching disconnects the Cursor app from the current workspace, so Grok Build stops listing its repositories and Bugbot stops commenting there. The app stays installed in Bitbucket.

Then finish connecting the new workspace. In its Bitbucket workspace settings, under **Forge Apps**, select **Cursor**, click **Connect to Cursor**, and choose your Grok Build team. If the Cursor app isn't installed in that workspace yet, install it first.

**Bitbucket Data Center**

> [!NOTE]
>
> Bitbucket Data Center requires a [Teams](/build/agents-window/account/teams/pricing) or [Enterprise](/build/agents-window/enterprise) plan. It supports Bugbot. Cloud Agents are not supported.

### Prerequisites

* Grok Build team admin access
* A dedicated Bitbucket Data Center service account
* An HTTP access token for the service account
* Repository admin access for the service account on each repository you want to use with Bugbot
* An incoming application link in Bitbucket Data Center with **Repositories Write** permission

The service account reads repositories and pull requests, manages webhooks, and posts Bugbot comments and build statuses. Members connect their own Bitbucket accounts through the application link.

A Grok Build team admin registers the instance under the team. Personal Bitbucket Data Center instances aren't supported.

### Networking

Grok Build needs HTTPS access to your Bitbucket Data Center instance for API requests and Git clones. Your instance also needs outbound HTTPS access to send webhook notifications to Grok Build.

#### IP allowlisting (recommended)

Add these Grok Build IP addresses to your inbound allowlist:

```text
184.73.225.134
3.209.66.12
52.44.113.131
100.63.97.141
100.63.144.57
18.210.232.136
3.208.51.163
3.224.130.48
3.234.118.132
34.197.19.148
34.198.251.120
34.199.187.247
35.170.160.152
44.215.226.85
52.202.172.69
54.81.109.217
54.204.61.44
54.236.99.119
67.202.63.191
184.193.125.229
184.193.223.40
184.194.140.210
184.194.175.144
184.194.208.56
```

If Grok Build should reach the instance through a load balancer or another URL than the one users open in the browser, enter it as the outbound URL during registration.

For instances without public inbound access, see [Advanced networking](#advanced-networking).

### Register with Grok Build

1. Create an HTTP access token for the Bitbucket service account
2. Go to [Integrations in the dashboard](https://grok.com/dashboard/integrations)
3. Open **Advanced**, then select **Bitbucket Data Center**
4. Enter the **Bitbucket Browser URL**, the URL users open in the browser, including any path prefix
5. If Grok Build needs a different URL for API and Git requests, enter it as the **Outbound URL (optional)**
6. Enter the **Service Account Token**
7. In Bitbucket Data Center, create an incoming application link with the redirect URL shown in the form and **Repositories Write** permission
8. Enter the link's **Application Link Client ID** and **Application Link Client Secret**
9. Click **Register**
10. Open [Bugbot in Automations](https://cursor.com/automations/from-cursor/bugbot) to enable it on repositories from the instance

Grok Build checks the instance's OAuth token endpoint when you register. The instance stays off until both the service account token and the application link are set. While it's off, Grok Build can't list its repositories or run Bugbot on them, and it drops the instance's webhook deliveries.

Grok Build uses the service account identity for Bugbot review comments, inline findings, webhooks, and build statuses.

Bugbot reviews pull requests automatically when they're opened or updated. Comment commands such as `bugbot run` and `cursor review` don't run on Bitbucket Data Center. Grok Build replies to the comment to say so.

[Bugbot Autofix](/build/agents-window/bugbot#autofix) isn't supported on Bitbucket Data Center. If Autofix is on, Bugbot skips it and says so in its review.

### Disconnect Bitbucket Data Center

Go to [Integrations in the dashboard](https://grok.com/dashboard/integrations), open the Bitbucket Data Center configuration page, and delete the registered instance. Revoke the service account token in Bitbucket Data Center after removing the instance from Grok Build.

## Advanced networking

Bitbucket Data Center supports private connection methods for instances that cannot accept traffic from the public internet.

**AWS PrivateLink or Cloudflare Tunnel**

Available for Enterprise customers. Allow Grok Build to access your instance over a private network connection. See [Private Connectivity](/build/agents-window/cloud-agent/private-connectivity) or [contact your Grok Build representative](https://cursor.com/contact-sales?source=docs-bugbot-private-network) for setup.

**Best for:** Instances behind a firewall, including AWS-hosted instances and environments that can run `cloudflared`

**Security:** HTTPS encryption, AWS PrivateLink, Cloudflare Tunnel, VPC allowlisting, service account access tokens

**Drawbacks:** Requires coordination with Grok Build. Google Private Service Connect is not currently supported.

**Reverse Proxy Tunnel**

Available for Enterprise customers. Run a reverse proxy tunnel on-premises that establishes an outbound connection to Grok Build. Network requests are forwarded through the tunnel, so the Bitbucket instance does not need public inbound access. [Contact your Grok Build representative](https://cursor.com/contact-sales?source=docs-bugbot-on-prem-proxy) for setup.

**Best for:** Environments without inbound network access

**Security:** HTTPS encryption, service account access tokens

**Drawbacks:** Introduces additional complexity, maintenance requirements, and potential security considerations compared to more direct connection methods

## Troubleshooting

**Grok Build cannot find my Bitbucket workspace**

Bitbucket app installation events can take a few minutes to sync. Wait and retry the **Connect to Cursor** step from Bitbucket workspace settings.

**I installed the Cursor app but cannot link it to my Grok Build team**

* Confirm you are a Grok Build team admin. Installing the app requires a Bitbucket workspace admin, but linking the workspace to a Grok Build team requires a Grok Build team admin.
* Confirm your Bitbucket user has access to the workspace you are linking.

**Bugbot comments do not appear as the Cursor app**

Install the Cursor app in the Bitbucket workspace and link it to your Grok Build team. A personal Bitbucket connection alone is not enough for comments from the Cursor app.

**Cloud Agent cannot access a Bitbucket repository**

* Connect your personal Bitbucket account from the integrations dashboard.
* Confirm your Bitbucket user has read-write access to the repository.
* Confirm the repository is on Bitbucket Cloud at `bitbucket.org`.

**Grok Build cannot list my Bitbucket Data Center repositories**

* Grok Build lists the team's Bitbucket Data Center repositories with your own linked Bitbucket account, not the service account. Connect your account from [Integrations in the dashboard](https://grok.com/dashboard/integrations), or click **Reconnect** if the link has expired.
* If you can't connect your account, ask a team admin to turn on account linking for the instance in its **Application link** settings.
* Confirm your Bitbucket user can access the repositories.
* Confirm Grok Build can reach the instance hostname or configured external host over HTTPS.

**I cannot enable Bugbot on a Bitbucket Data Center repository**

* Confirm you are a Grok Build team admin.
* Confirm the registered instance has a service account token.
* Confirm the registered instance has an application link client ID and client secret. If the instance is off, a team admin sets them from the instance's **Application link** settings.
* Confirm the service account has repository admin access.

## Next steps

Once Bitbucket is connected, configure the features that use it:

* [Bugbot](/build/agents-window/bugbot) - automated PR reviews that catch bugs and security issues
* [Cloud Agents](/build/agents-window/cloud-agent) - AI agents for Bitbucket Cloud repositories
