@percy/env
This package provides various CI/CD support for Percy by coalescing different environment variables
into a common interface for consumption by @percy/client.
Supported Environments
Auto-detected based on environment variables that the CI provider sets during a build.
Opt-in Environments
Kubernetes-native pipelines do not inject provider-identifying environment variables
into step containers by default. To enable Percy detection on these systems, expose
the following variables via template substitution in your pipeline definition.
Tekton Pipelines
steps:
- name: percy
image: node:20
env:
- name: TEKTON_PIPELINE_RUN
value: "$(context.pipelineRun.name)"
- name: TEKTON_COMMIT_SHA
value: "$(params.commit-sha)"
- name: TEKTON_BRANCH
value: "$(params.branch)"
- name: TEKTON_PULL_REQUEST
value: "$(params.pr-number)"
Argo Workflows
- name: percy
container:
image: node:20
env:
- name: ARGO_WORKFLOW_NAME
value: "{{workflow.name}}"
- name: ARGO_WORKFLOW_UID
value: "{{workflow.uid}}"
- name: ARGO_COMMIT_SHA
value: "{{workflow.parameters.commit-sha}}"
- name: ARGO_BRANCH
value: "{{workflow.parameters.branch}}"
- name: ARGO_PULL_REQUEST
value: "{{workflow.parameters.pr-number}}"
Vercel
Vercel exposes its VERCEL_* system environment variables to the build step only
when Automatically expose System Environment Variables is enabled on the project
(Settings → Environment Variables). Percy also needs PERCY_PARALLEL_TOTAL=-1
set in the project environment for the parallel nonce to populate from
VERCEL_DEPLOYMENT_ID — otherwise reruns of the same deploy will create separate
Percy builds instead of deduping.
Percy Environment Variables
The following variables may be defined to override the respective derived CI environment variables.
PERCY_COMMIT
PERCY_BRANCH
PERCY_PULL_REQUEST
PERCY_PARALLEL_NONCE
PERCY_PARALLEL_TOTAL
Additional Percy specific environment variable may be set to control aspects of your Percy build.
PERCY_TARGET_COMMIT
PERCY_TARGET_BRANCH
PERCY_PARTIAL_BUILD
Adding Environment Support
- Add CI detection to
environment.js
- Add respective environment variables
- Add a dedicated CI test suite
- Open a Pull Request!