> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.governanceaicore.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.governanceaicore.com/_mcp/server.

# Bitbucket Integration

> Connect Bitbucket Cloud or Server for AI scanning

# Bitbucket Integration

Integrate GovernanceAI with Bitbucket Cloud or Server for automated AI governance scanning.

## Bitbucket Cloud Setup

### Step 1: Create OAuth Consumer

* Bitbucket Cloud → **Workspace Settings** → **OAuth consumers**
* **Create consumer** with scopes:
  * `repository:read`
  * `pullrequest:read`
* Copy Client ID and Secret

### Step 2: Connect in GovernanceAI

* **Integrations** → **Bitbucket Cloud**
* Click **Connect**
* Authorize GovernanceAI
* Select repositories

## Bitbucket Server/Data Center Setup

### Step 1: Create App Password

* **Personal Settings** → **App passwords**
* Create password with permissions:
  * `repository:read`
  * `pullrequest:read`
* Copy credentials

### Step 2: Connect in GovernanceAI

* **Integrations** → **Bitbucket Server**
* Enter Server URL
* Enter username and password
* Select repositories

## Scanning Features

✅ **Automatic Scanning**

* On push to main branches
* On pull requests
* Scheduled scans

✅ **PR Integration**

* Findings in PR comments
* Build status checks
* Block on critical findings

## Bitbucket Pipelines Integration

```yaml
# bitbucket-pipelines.yml
image: atlassian/default-image:2

pipelines:
  branches:
    main:
      - step:
          name: GovernanceAI Scan
          script:
            - |
              curl -X POST https://api.governanceai.com/v1/scans \
                -H "Authorization: Bearer $GOVERNANCEAI_API_KEY" \
                -d '{
                  "repository": "'$BITBUCKET_REPO_FULL_NAME'",
                  "ref": "'$BITBUCKET_COMMIT'"
                }'
```

## Cloud vs Server

| Feature     | Cloud     | Server       |
| ----------- | --------- | ------------ |
| Setup       | OAuth     | App Password |
| Webhooks    | Automatic | Manual       |
| Complexity  | Simple    | More steps   |
| Self-hosted | No        | Yes          |

## Troubleshooting

* **OAuth timeout** - Check network connectivity
* **Repositories not showing** - Verify permissions
* **Webhooks not firing** - Check webhook delivery in Bitbucket
* **Build status not updating** - Verify build permission

## Next Steps

* **[Jira Integration](/integrations/jira)** - Track issues
* **[Running Scans](/usage-guides/scans)** - Scan your code
* **[API Reference](/api)** - Integration APIs