Bitbucket
Connect MergeGuide to Bitbucket to run compliance checks on every pull request. Violations are posted as inline comments and PR merges can be blocked until checks pass.Supported Features
- Pull request policy gate (block on violation)
- Inline code comments on violations
- Build status reporting
- Bitbucket Pipelines integration
- Bitbucket Cloud and Bitbucket Server/Data Center support
Bitbucket Cloud Setup
OAuth Consumer
Create an OAuth consumer
In Bitbucket, go to your workspace Settings > Apps and features > OAuth consumers > Add consumer.
- Name: MergeGuide
- Callback URL:
https://portal.mergeguide.ai/integrations/bitbucket/callback - Permissions:
- Repositories: Read
- Pull requests: Read, Write
- Webhooks: Read and write
Connect in MergeGuide
Go to Settings > Integrations > Bitbucket > Connect. Enter the Key and Secret, then authorize.
App Password (Alternative)
If OAuth is not available, use an app password:- Go to your Bitbucket account Personal settings > App passwords > Create app password
- Grant permissions: Repositories (Read), Pull requests (Read, Write), Webhooks (Read and write)
- In MergeGuide, go to Settings > Integrations > Bitbucket > Connect with App Password
- Enter your Bitbucket username and the app password
App passwords are tied to individual user accounts. Use a dedicated service account for production integrations to prevent disruption if a user’s account is deactivated.
Webhook Configuration
MergeGuide registers webhooks automatically during OAuth setup. To register manually:- In Bitbucket, go to the repository Repository settings > Webhooks > Add webhook
- Configure:
- Title: MergeGuide
- URL:
https://portal.mergeguide.ai/webhooks/bitbucket - Triggers: Pull Request: Created, Updated, Approved; Repository: Push
- Save the webhook
Pull Request Gate
MergeGuide posts a build status to every PR. Configure the gate in Settings > Integrations > Bitbucket > Gate Settings:| Setting | Options |
|---|---|
| Gate mode | Advisory (comment only) or Blocking (require passing status) |
| Violation severity | Block on Error only, or Error + Warning |
Blocking PRs (Bitbucket Cloud)
- Go to repository Repository settings > Branch restrictions
- Add a restriction on your main branch:
- Check Require passing builds before merging
- MergeGuide reports under the key
mergeguide/compliance
Bitbucket Pipelines Integration
Add MergeGuide to your pipeline:MERGEGUIDE_API_KEY and MERGEGUIDE_ORG_ID as repository variables under Repository settings > Repository variables. Mark them Secured to prevent exposure in logs.
Available --fail-on values: never, warning, error
Bitbucket Server / Data Center
MergeGuide supports Bitbucket Server 7.0+ and Bitbucket Data Center.Configuration
- Go to Settings > Integrations > Bitbucket > Advanced
- Enter your Bitbucket Server URL:
https://bitbucket.example.com - Create a personal access token in Bitbucket Server: Account > Manage account > Personal access tokens
- Permissions: Projects (Read), Repositories (Read), Pull requests (Write)
- Enter the token in MergeGuide
Bitbucket Server must be reachable from MergeGuide’s servers for webhook delivery. For air-gapped environments, use the MergeGuide CLI to push results from inside your network rather than relying on webhooks.
Webhooks on Bitbucket Server
Bitbucket Server uses project-level or repository-level webhooks. Register at: Repository settings > Hooks > Add webhook.Inline Comments
MergeGuide posts violation comments on the relevant PR diff lines:Troubleshooting
”Insufficient permissions” on PR comment
The OAuth consumer or app password requires Pull requests: Write permission to post comments. Recreate the credentials with the correct permissions.Build status not appearing on PR
- Verify the repository is enabled under Settings > Integrations > Bitbucket
- Confirm webhooks are registered and active in Bitbucket
- Check that PR events are included in the webhook triggers
Webhook deliveries failing (Bitbucket Server)
Check Repository settings > Hooks for the webhook delivery log. Common causes: network firewall between your Bitbucket Server andportal.mergeguide.ai, or SSL certificate validation failure.