GitLab CI
Integrate VigilQA into your GitLab CI/CD pipeline to run tests on every push and gate deployments on results.
Prerequisites
- A VigilQA project with at least one approved test plan
- A VigilQA API token stored as a GitLab CI/CD variable:
VIGILQA_API_TOKEN(masked)
GitLab CI configuration
# .gitlab-ci.yml
vigilqa:
stage: test
image: alpine:3.18
before_script:
- apk add --no-cache curl jq
script:
# Trigger run
- |
RUN_ID=$(curl -s -X POST \
"https://api.sentinelflux.in/v1/runs" \
-H "Authorization: Bearer $VIGILQA_API_TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"project\": \"myapp\",
\"plan\": \"regression\",
\"context\": {
\"commit_sha\": \"$CI_COMMIT_SHA\",
\"branch\": \"$CI_COMMIT_REF_NAME\",
\"pipeline_id\": \"$CI_PIPELINE_ID\"
}
}" | jq -r '.run_id')
echo "Run ID: $RUN_ID"
# Poll for completion
- |
while true; do
RESULT=$(curl -s \
"https://api.sentinelflux.in/v1/runs/$RUN_ID" \
-H "Authorization: Bearer $VIGILQA_API_TOKEN")
STATUS=$(echo $RESULT | jq -r '.status')
case $STATUS in
passed) echo "All tests passed"; exit 0 ;;
failed) echo "Tests failed"; exit 1 ;;
error) echo "Run error"; exit 1 ;;
*) sleep 15 ;;
esac
done
Store VIGILQA_API_TOKEN as a masked CI/CD variable in GitLab → Settings → CI/CD → Variables. Masked variables are hidden in job logs.
Targeting different environments per branch
vigilqa:
script:
- |
ENVIRONMENT="staging"
if [[ "$CI_COMMIT_REF_NAME" == "main" ]]; then
ENVIRONMENT="production-readonly"
fi
curl -s -X POST "https://api.sentinelflux.in/v1/runs" \
-H "Authorization: Bearer $VIGILQA_API_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"project\":\"myapp\",\"plan\":\"regression\",\"environment\":\"$ENVIRONMENT\"}"