Other CI providers

The CLI runs anywhere it can reach https://visualci.com. It needs a project token and three facts about the run: the commit, the branch and, for pull requests, the number.

Environment variables

Variable What it is
VISUALCI_TOKEN A project token (vci_...). Required.
VISUALCI_BUILD_ID The build that upload and finalize add to. Set it from visualci build create.
VISUALCI_COMMIT The commit the files come from. Default: your CI provider's variable (below), then git rev-parse HEAD.
VISUALCI_BRANCH The branch. Default: your CI provider's variable, then git rev-parse --abbrev-ref HEAD.
VISUALCI_PR The pull request number. Default: your CI provider's variable. Set it to false for no pull request.
VISUALCI_API_URL The server, for self-hosting. Default: https://visualci.com.

CI providers the CLI reads

The CLI works out which provider it's running on and reads that provider's variables. On a pull request it reports the branch's own commit and name, where the provider gives them, rather than a merge commit and the target branch.

Provider Commit Branch Pull request
CircleCI CIRCLE_SHA1 CIRCLE_BRANCH CIRCLE_PULL_REQUEST
GitHub Actions the event's head commit, or GITHUB_SHA GITHUB_HEAD_REF, or GITHUB_REF_NAME the event's number
Buildkite BUILDKITE_COMMIT BUILDKITE_BRANCH BUILDKITE_PULL_REQUEST
GitLab CI CI_MERGE_REQUEST_SOURCE_BRANCH_SHA, or CI_COMMIT_SHA CI_MERGE_REQUEST_SOURCE_BRANCH_NAME, or CI_COMMIT_REF_NAME CI_MERGE_REQUEST_IID
Jenkins GIT_COMMIT CHANGE_BRANCH, BRANCH_NAME, or GIT_BRANCH CHANGE_ID
Bitbucket Pipelines BITBUCKET_COMMIT BITBUCKET_BRANCH BITBUCKET_PR_ID
Semaphore SEMAPHORE_GIT_PR_SHA, or SEMAPHORE_GIT_SHA SEMAPHORE_GIT_PR_BRANCH, or SEMAPHORE_GIT_BRANCH SEMAPHORE_GIT_PR_NUMBER
Travis CI TRAVIS_PULL_REQUEST_SHA, or TRAVIS_COMMIT TRAVIS_PULL_REQUEST_BRANCH, or TRAVIS_BRANCH TRAVIS_PULL_REQUEST

On Jenkins, GIT_COMMIT and GIT_BRANCH come from the Git plugin, and CHANGE_* and BRANCH_NAME from multibranch pipelines.

Other providers

Elsewhere, set the variables yourself. Most CI systems check out a commit without a branch, so git rev-parse --abbrev-ref HEAD prints HEAD and the build would record that as its branch. On TeamCity, for example:

export VISUALCI_COMMIT="%build.vcs.number%"
export VISUALCI_BRANCH="%teamcity.build.branch%"

The commit's history

visualci build create sends up to 100 ancestor commits from git rev-list. VisualCI compares the build with the approved build of the nearest one, and falls back to the default branch's latest approved build. A shallow clone has no ancestors to send, so every build compares with the default branch. Fetch enough history before creating the build.

Parallel jobs

Parallel jobs can share one build:

  • Each job runs visualci build create --nonce <id> --shards <n>. The same nonce returns the same build, so pick something all the jobs share, such as the workflow's id plus the job's name.
  • Each job uploads its files and runs visualci build finalize --shard <i>, with shards numbered from 0.
  • VisualCI compares the build once all n shards have finalized.

Add --subset when some jobs may not run. Snapshots that weren't sent are then carried forward instead of counted as removed.

Several suites in one project

visualci build create --name <suite> keeps separate builds, and separate baselines, for suites that run in different jobs, such as --name rspec and --name jest.

Waiting for the result

visualci build finalize --wait waits until VisualCI has compared the build and prints what changed. It exits 0 when CI should pass, 1 when it should fail, and 3 when it timed out. Under the default review mode a build with changes still passes: the GitHub check holds the pull request instead. See GitLab CI for the other modes.