Search documentation

Search all documentation pages

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

1

Connect via OAuth

Go to Integrations > Add Integration > Bitbucket in the Aguardic dashboard and click Connect. You'll be redirected to Bitbucket to authorize Aguardic to access your repositories.
2

Bind policies

After connecting, go to Policy Bindings and map your policies to the Bitbucket integration. You can bind policies to:

All repositoriesEvery repository connected through the integration
Specific repositoriesIndividual repositories selected by name
Specific branchesTarget branches like main or production
3

Configure enforcement

Choose how Aguardic enforces policy results on Bitbucket:

BLOCKSets the build status to FAILED, preventing merge when merge checks are enabled
APPROVAL_REQUIREDSets the build status to INPROGRESS, requiring manual resolution before merge
WARNSets the build status to SUCCESSFUL but includes violation details in the status description
MONITOR_ONLYNo visible action on Bitbucket, violations logged in Aguardic only

How It Works

1

PR opened or updated

A developer opens or updates a pull request
2

Webhook received

Bitbucket sends a webhook to Aguardic
3

Fetch PR data

Aguardic fetches the PR diff and metadata
4

Policy evaluation

The governance engine evaluates against bound policies
5

Report results

Results are posted as a build status on the pull request

What Gets Evaluated

PR title and descriptionCheck naming conventions and required sections
File changesScan diffs for sensitive data, banned patterns, or restricted file types
Commit messagesEnforce commit message format
Branch namesValidate branch naming conventions

Merge Checks

For full enforcement, configure merge checks in your Bitbucket repository:

  1. Go to Repository Settings > Merge checks
  2. Enable "Minimum successful builds" and set it to include the Aguardic check
  3. 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