Hey! These docs are for version 1, which is no longer officially supported. Click here for the latest version, 2!

GitLab CI

This doc will walk you through implementing Percy into your GitLab CI environment. See separate docs to integrate with GitLab.com.

Percy is designed to integrate with your tests and CI environment. To enable Percy, the token environment variable must be configured in your CI service:

  • PERCY_TOKEN: The Percy repo write-only API token. This is unique for each Percy repository.

GitLab pipeline setup


GitLab provides an easy way to set environment variables in your build pipeline config or agent hooks. Shown below is a minimal CI config that has the necessary variables to make Percy work smoothly:

---
test:
  variables:
    - GITLAB_CI
    - CI_COMMIT_SHA
    - CI_COMMIT_REF_NAME
    - CI_JOB_ID
    - CI_SERVER_VERSION
    - PERCY_TOKEN

To configure environment variables, navigate to your GitLab repository, then go to Settings > CI/CD > and then expand the Variables section.

Then set PERCY_TOKEN to the write-only token from your Percy repo. This token can be found in each Percy repo's settings.

🚧

IMPORTANT: Keep your Percy token secret. Anyone with access to your token can consume your account quota, though they cannot read data.

Next step: integrate with tests


You're done with setup---the last step is to integrate Percy into your tests and run them. Just choose your client library:

JavaScript

Ruby

Python

Static sites

Everything else