Skip to main content

GitLab CI Integration

Add DriftWise to your .gitlab-ci.yml pipeline.

Pipeline Example

.gitlab-ci.yml
plan:
stage: plan
script:
- terraform plan -out=tfplan
- terraform show -json tfplan > plan.json
- |
curl -sX POST "https://app.driftwise.ai/api/v2/orgs/$DRIFTWISE_ORG_ID/analyze" \
-H "x-api-key: $DRIFTWISE_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"plan_json\": $(cat plan.json | jq -Rs .),
\"ci\": {
\"repo_owner\": \"$CI_PROJECT_NAMESPACE\",
\"repo_name\": \"$CI_PROJECT_NAME\",
\"pr_number\": $CI_MERGE_REQUEST_IID,
\"commit_sha\": \"$CI_COMMIT_SHA\",
\"branch\": \"$CI_COMMIT_BRANCH\"
}
}"

CI/CD Variables

Add these in your project settings (Settings > CI/CD > Variables):

VariableTypeMaskedValue
DRIFTWISE_API_KEYVariableYesYour API key (dw2_...)
DRIFTWISE_ORG_IDVariableNoYour organization ID

Notes

  • jq must be available in your CI runner image (most Terraform images include it)
  • The ci metadata block is optional but helps DriftWise link the analysis to the merge request
  • The response is synchronous with up to a 120-second timeout