GitLab CI

On this page

You can easily run your checks on demand as part of your GitLab CI pipelines using the Checkly command line trigger.

GitLab CI example

To start off, you will need to set your CHECKLY_TOKEN as an environment variable for your pipeline.

GitLab Checkly Token Config

This secret value will allow you to use the Checkly trigger to start your check on demand. Having the value masked prevents it from showing up in your logs.

Note: the Checkly Token is the very last part of the check’s command line trigger URL.

The .gitlab-ci.yml file, which you can also find on our checkly-ci-test GitHub repo, is where you will define how your GitLab CI pipeline will look. We will be defining some basic placeholder steps, which you should rearrange to match your use case. Note the post-deployment trigger_checkly step to trigger Checkly checks and mark the build passed or failed depending on the outcome.

  - build
  - test
  - deploy
  - trigger_checkly

image: curlimages/curl

  stage: build
    - echo "Building..."

  stage: test
    - echo "Running tests..."

  stage: deploy
    - echo "Deploying..."

  stage: trigger_checkly
    - echo "Deployment finished."
    # Call Checkly trigger
    - curl "$CHECKLY_TOKEN" > $PWD/checkly.json
    # Exit with an error status if we find more than 0 "hasFailures: true" in the output
    - if [ $(grep -c '"hasFailures":true' $PWD/checkly.json) -ne 0 ]; then exit 1; fi
This is a v1 integration. We are working on providing better feedback, longer runs, GitHub PR feedback and more customization options for checks triggered directly via the API.
The total run time of all checks cannot exceed 30 seconds or you will receive a timeout error.

You can contribute to this documentation by editing this page on Github