How to use ClearRun in GitLab CI or any other CI

Run npx -y @clearrun/cli@1.2.0 score in a job that has Node.js 18 or newer and a CLEARRUN_API_KEY secret. The CLI exits 1 when an answer fails, which fails the job in any CI.

Last updated

Steps

  1. Add the key as a masked secret variable

    Name it CLEARRUN_API_KEY.

  2. GitLab CI example

    In .gitlab-ci.yml:

    clearrun:
      image: node:20
      script:
        - npx -y @clearrun/cli@1.2.0 score --threshold 70
  3. Any other CI

    npx -y @clearrun/cli@1.2.0 score responses/ --threshold 70 --json > clearrun.json

    Keep clearrun.json as a build artifact if you want the verdict ids.

Exit codes

0 passed, 1 failed. There are no others. See What do the ClearRun CLI exit codes mean?