GitLab CI Integration
Integrate Cloudgeni security scanning into your GitLab CI/CD pipelines to automatically check Infrastructure as Code for security issues on every push and merge request.What You'll Get
- Automated security scanning in your CI/CD pipeline
- Merge request gates that block insecure code
- SAST integration with GitLab Security Dashboard
- Fail-on-severity configuration for quality gates
- Detailed reports in merge request widgets
Prerequisites
Before You Start
Before You Start
- GitLab repository with CI/CD enabled
- Cloudgeni account and API key
- Repository containing IaC files (
.tf,.bicep,.hcl,.yaml, etc.)
Quick Start
Step 1: Create API Key
- Go to Settings → API Keys in Cloudgeni
- Click Create API Key
- Name it
gitlab-ci - Copy the generated key
Step 2: Add CI/CD Variable
- Go to your GitLab project
- Navigate to Settings → CI/CD → Variables
- Click Add variable
- Configure:
- Key:
CLOUDGENI_API_KEY - Value: Your API key
- Type: Variable
- Flags: Mask variable, Protect variable
- Key:
- Click Add variable
Step 3: Add Pipeline Job
Add to your.gitlab-ci.yml:
Configuration Options
Scanner Options
| Option | Description | Default |
|---|---|---|
--api-key | Cloudgeni API key | Required |
--fail-on-critical | Exit 1 on critical findings | false |
--fail-on-high | Exit 1 on high findings | false |
--fail-on-medium | Exit 1 on medium findings | false |
--path | Directory to scan | . |
--exclude | Paths to exclude | None |
--output | Output format (text, json, sarif) | text |
Basic Job
Strict Mode
Custom Path
Pipeline Examples
Basic Pipeline
Production Pipeline
Multi-Environment Pipeline
Only Scan Changed Files
Merge Request Integration
MR Widget
Security findings appear in the merge request:- Security widget shows findings summary
- Click to expand detailed view
- Links to Cloudgeni dashboard
Blocking Merges
Configure merge request approvals:- Go to Settings → Merge requests
- Enable Pipelines must succeed
- Security job will block merge on failures
SARIF Reports
Enable GitLab Security Dashboard integration:Group-Level Variables
For multiple projects:- Go to Group Settings → CI/CD → Variables
- Add
CLOUDGENI_API_KEYat group level - All projects in group can use the variable
- Override at project level if needed
Caching
Speed up scans with caching:Scheduled Scans
Run regular security scans:Troubleshooting
Common Issues
Common Issues
Variable Not Found:
- Check variable name matches exactly
- Verify variable is not protected (for unprotected branches)
- Check variable scope (project vs group)
- Verify API key is correct
- Check key hasn’t expired
- Ensure variable is masked but accessible
- Verify Docker is enabled for CI/CD
- Check container registry access
- Try
docker pull cloudgeni/scanner:latestlocally
- Large repositories take longer
- Add
timeout: 30mto job - Consider scanning specific paths
- Ensure
--output sarifis specified - Check artifact path is correct
- Verify job completed successfully