Bitbucket Integration
Enforce policies on Bitbucket pull requests.
Overview
The Bitbucket integration connects Aguardic to your Bitbucket repositories via OAuth. When pull requests are created or updated, Aguardic evaluates the changes against your policies and reports results as build statuses on the pull request.
Setup
Connect via OAuth
Bind policies
After connecting, go to Policy Bindings and map your policies to the Bitbucket integration. You can bind policies to:
main or productionConfigure enforcement
Choose how Aguardic enforces policy results on Bitbucket:
FAILED, preventing merge when merge checks are enabledINPROGRESS, requiring manual resolution before mergeSUCCESSFUL but includes violation details in the status descriptionHow It Works
PR opened or updated
Webhook received
Fetch PR data
Policy evaluation
Report results
What Gets Evaluated
Merge Checks
For full enforcement, configure merge checks in your Bitbucket repository:
- Go to Repository Settings > Merge checks
- Enable "Minimum successful builds" and set it to include the Aguardic check
- Aguardic's build status will block merges when violations are found
With merge checks enabled and enforcement set to BLOCK, developers cannot merge PRs that violate your policies.
Example Policies
Require PR Reviewers
Ensure pull requests have at least one reviewer assigned:
- Field:
reviewers - Operator:
GTE - Value:
1 - Severity: MEDIUM
Block Banned File Types
Prevent certain file types from being committed (e.g., compiled binaries):
- Field:
files - Operator:
MATCHES - Value:
\.(exe|dll|bin|so)$ - Severity: HIGH
Enforce Commit Message Format
Require conventional commit messages:
- Field:
commit_message - Operator:
MATCHES - Value:
^(feat|fix|chore|docs|refactor|test|ci)(\(.+\))?: .{10,} - Severity: LOW
Next Steps
- GitHub Integration — Similar setup for GitHub
- GitLab Integration — Similar setup for GitLab
- Your First Policy — Deep dive into policy creation