GitLab Integration
Enforce policies on GitLab merge requests and pipelines.
Overview
The GitLab integration connects Aguardic to your GitLab projects via OAuth. When merge requests are opened or updated, Aguardic evaluates the changes against your policies and reports results as commit statuses on the merge request.
Setup
Connect via OAuth
Bind policies
After connecting, go to Policy Bindings and map your policies to the GitLab integration. You can bind policies to:
main or productionConfigure enforcement
Choose how Aguardic enforces policy results on GitLab:
failed, preventing merge when pipeline status checks are requiredpending, requiring manual intervention before mergesuccess but includes violation details in the status descriptionHow It Works
MR opened or updated
Webhook received
Fetch MR data
Policy evaluation
Report results
What Gets Evaluated
feature/, fix/)Pipeline Integration
For full enforcement, configure your GitLab project to require pipeline success before merging:
- Go to Settings > Merge requests in your GitLab project
- Under "Merge checks", enable "Pipelines must succeed"
- Aguardic's commit status will be included in the pipeline check
With pipeline checks enabled and enforcement set to BLOCK, developers cannot merge MRs that violate your policies.
Example Policies
Enforce MR Description Format
Require merge requests to include a structured description:
- Field:
description - Operator:
MATCHES - Value:
## (Summary|Changes|What)(must include a markdown heading) - Severity: MEDIUM
Block Secrets in Commits
Prevent credentials from being committed:
- Field:
content - Operator:
MATCHES - Value:
(AKIA[A-Z0-9]{16}|-----BEGIN (RSA |EC )?PRIVATE KEY-----|sk-[a-zA-Z0-9]{48}) - Severity: CRITICAL
Enforce Branch Naming
Require branches to follow a naming convention:
- Field:
branch - Operator:
MATCHES - Value:
^(feature|fix|hotfix|release)/[a-z0-9-]+$ - Severity: LOW
Next Steps
- GitHub Integration — Similar setup for GitHub
- Bitbucket Integration — Similar setup for Bitbucket
- Your First Policy — Deep dive into policy creation