ContactSign inSign up
Contact

Back to all FAQs

How to set Chromatic environment variables in popular CI providers?

Environment variables define settings for your CI workflow which Chromatic relies on to get git context, such as the current commit SHA and branch name. Below are examples on how to set them for some popular CI providers:

CI ProviderCHROMATIC_SHACHROMATIC_BRANCHCHROMATIC_SLUG
GitHub Actions (Push)GITHUB_SHAGITHUB_REF_NAMEGITHUB_REPOSITORY
GitHub Actions (Pull Request)github.event.pull_request.head.shagithub.head_refGITHUB_REPOSITORY
GitLabCI_COMMIT_SHACI_COMMIT_REF_NAMECI_PROJECT_PATH
Bitbucket PipelinesBITBUCKET_COMMITBITBUCKET_BRANCHBITBUCKET_REPO_FULL_NAME
Bitbucket WorkspacesBITBUCKET_COMMITBITBUCKET_BRANCH${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}
CircleCICIRCLE_SHA1CIRCLE_BRANCH${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}
Semaphore (Push)SEMAPHORE_GIT_SHASEMAPHORE_GIT_BRANCHSEMAPHORE_PROJECT_NAME
Semaphore (Pull Request)SEMAPHORE_GIT_PR_SHASEMAPHORE_GIT_WORKING_BRANCHSEMAPHORE_PROJECT_NAME
TravisCITRAVIS_COMMITTRAVIS_BRANCHTRAVIS_REPO_SLUG
JenkinsGIT_COMMITGIT_BRANCH{org}/{repo}
Azure PipelinesBUILD_SOURCEVERSIONBUILD_SOURCEBRANCHNAME{org}/{repo}
BuildkiteBUILDKITE_COMMITBUILDKITE_BRANCH${BUILDKITE_ORGANIZATION_SLUG}/${BUILDKITE_PIPELINE_SLUG}

Considerations

Some CI providers have unique behaviors that require special configuration.

GitHub Actions pull requests

When a workflow runs on a pull request, the default GITHUB_SHA and GITHUB_REF_NAME variables refer to the temporary merge commit, not the head of the source branch.

To get the correct commit and branch, you must access the head context from the pull request event.

GitLab merge requests

If your merge request pipeline runs on an ephemeral merge commit, you should override the default variables to ensure Chromatic tracks the correct source branch.

Bitbucket Pipelines

Bitbucket may create an ephemeral merge commit if the source branch is not up-to-date with the target branch (e.g., main). This can cause the BITBUCKET_COMMIT to differ from the commit you expect.

Jenkins

In Jenkins, some variables like BUILD_ID and BUILD_URL are available globally across all jobs. However, Git-specific variables like GIT_COMMIT and GIT_BRANCH are typically defined within a Jenkinsfile and must be accessed from there.

GitHub Merge Queue

GitHub’s merge queue feature does not require any specific environment variable setup to work with Chromatic.

If your provider is not listed here, refer to their documentation to find the equivalent environment variables for commit SHA, branch name, and repository slug. If you need further assistance, please reach out to the Chromatic support at support@chromatic.com or via in-app chat.