Skip to content
RecipesDoc

Cypress Tests in GitLab, Run After Each Deploy

Your GitLab pipeline tells Certyn about each deploy, and Certyn runs your Cypress suite against the new version.

For teams with Cypress tests in GitLab who want them to run after every deploy to staging.

Your setup

  • Cypress tests in a GitLab repo.
  • A GitLab CI pipeline deploys the app to staging, on the internet.
  • You want the suite to run after each deploy, with a report.

Say this to Certyn

Our Cypress tests are in gitlab.com/acme/web. Run them against staging after every deploy.

What Certyn does

  1. Opens a form for a GitLab access token, saved as the secret project variable GITLAB_TOKEN. The read_repository scope is enough to run tests.
  2. On a Machine, clones over https with a git credential helper that reads GITLAB_TOKEN. The token never goes in a URL.
  3. Runs one spec to check the install and the URL, and saves the repo and test command as project variables.
  4. Creates an agent process with the goal: clone the repo, install, run npx cypress run against this environment, report.
  5. Turns on "after each deploy" for staging (app.process.trigger.set with on_deploy). You approve it. A deploy is a new environment version.
  6. Gives you a job to add after your deploy job. It sets the new version:
curl -sS -X PUT \
  "https://api.certyn.io/api/projects/$CERTYN_PROJECT_ID/environments/$CERTYN_ENVIRONMENT_ID" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $CERTYN_API_KEY" \
  -d "{\"version\": \"$CI_COMMIT_SHORT_SHA\"}"

The key needs the Projects scope (platform:manage). Create it in Settings → API Keys and save it as a masked GitLab CI variable.

What you get

  • A run after each deploy, for that version.
  • A run report with failures grouped by cause, and one issue per real product bug.
  • The version history of the environment.

Limits

  • A deploy-triggered run has 60 minutes. Split a longer suite into two processes.
  • The CI Runs API (POST /api/ci/runs) starts only Certyn test-case suites, not a goal. Set the version instead, as above.
  • The key from the ci_setup form has only CI scopes. It cannot change an environment.
  • Sending the same version again starts no run.
  • A staging app inside your network needs a self-hosted runner.