Skip to content

GitLab CI

Trigger Smoketest deployment webhooks from GitLab CI after an environment deployment.

View as Markdown

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

  1. Create a deployment webhook in Smoketest.
  2. Add a masked CI/CD variable named SMOKETEST_DEPLOYMENT_WEBHOOK_URL.
  3. Set CI_ENVIRONMENT_URL through a GitLab environment or replace it with your own deployed URL variable.

Deployment job

.gitlab-ci.yml
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:

.gitlab-ci.yml
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.

On this page