GitLab CI
Trigger Smoketest deployment webhooks from GitLab CI after an environment deployment.
Use GitLab CI when your deployment job already knows the environment URL. Smoketest can receive the deployed URL, commit SHA, branch, and pipeline ID directly from GitLab variables.
Before you start
- Create a deployment webhook in Smoketest.
- Add a masked CI/CD variable named
SMOKETEST_DEPLOYMENT_WEBHOOK_URL. - Set
CI_ENVIRONMENT_URLthrough a GitLab environment or replace it with your own deployed URL variable.
Deployment job
deploy:
stage: deploy
environment:
name: production
url: https://app.example.com
script:
- ./scripts/deploy.sh
smoketest:
stage: test
needs: ["deploy"]
script:
- |
curl -sf -X POST -G "$SMOKETEST_DEPLOYMENT_WEBHOOK_URL" \
-H "Idempotency-Key: $CI_PIPELINE_ID" \
--data-urlencode "targetUrl=$CI_ENVIRONMENT_URL" \
--data-urlencode "commitSha=$CI_COMMIT_SHA" \
--data-urlencode "branch=$CI_COMMIT_REF_NAME" \
--data-urlencode "externalId=$CI_PIPELINE_ID"Preview environments
For review apps, use GitLab's environment URL as targetUrl:
review-smoketest:
stage: test
needs: ["deploy-review"]
script:
- |
curl -sf -X POST -G "$SMOKETEST_DEPLOYMENT_WEBHOOK_URL" \
-H "Idempotency-Key: $CI_PIPELINE_ID-$CI_ENVIRONMENT_SLUG" \
--data-urlencode "targetUrl=$CI_ENVIRONMENT_URL" \
--data-urlencode "commitSha=$CI_COMMIT_SHA" \
--data-urlencode "branch=$CI_COMMIT_REF_NAME" \
--data-urlencode "externalId=$CI_PIPELINE_ID-$CI_ENVIRONMENT_SLUG"GitHub checks
GitHub checks only apply when the Smoketest webhook is bound to a mapped GitHub repository and commitSha belongs to that repository. For GitLab-only repositories, runs still queue and appear in Smoketest.