Buildkite

The CLI reads the commit from BUILDKITE_COMMIT, the branch from BUILDKITE_BRANCH and the pull request from BUILDKITE_PULL_REQUEST.

steps:
  - label: ":test_tube: Tests"
    command: |
      curl -fsSL https://visualci.com/install.sh | VISUALCI_INSTALL_DIR="$$HOME/bin" sh
      export PATH="$$HOME/bin:$$PATH"
      export VISUALCI_BUILD_ID=$$(visualci build create)
      npm test -- -u
      visualci upload --from auto src tests
      visualci build finalize

$$ keeps Buildkite from filling in the variables when the pipeline is uploaded, so the job's shell reads them when it runs.

Store VISUALCI_TOKEN (a project token) in your secrets manager or agent environment hook.

The commit's history helps VisualCI find the nearest approved ancestor. Buildkite's default checkout is a full clone; if you've made it shallow, deepen it before visualci build create.

Parallel jobs

For a step with parallelism, use the same nonce in every job and finalize each job's shard (in a script the step runs; in pipeline YAML, write $$ for $):

export VISUALCI_BUILD_ID=$(visualci build create --nonce "$BUILDKITE_BUILD_ID-$BUILDKITE_STEP_ID" --shards "$BUILDKITE_PARALLEL_JOB_COUNT")
# ... tests and uploads ...
visualci build finalize --shard "$BUILDKITE_PARALLEL_JOB"