Any other provider
If your provider isn’t detected automatically, give Selective the run’s context yourself. Every variable below is a plain environment variable on the job that runs the tests.
| Variable | Required | What it is |
|---|---|---|
SELECTIVE_API_KEY | Yes | The suite’s API key from the dashboard. |
SELECTIVE_PLATFORM | Yes | A short name for your CI, for example jenkins or gitlab. Shown in the dashboard. |
SELECTIVE_RUN_ID | Yes | Identifies one run of the suite. Same across reruns of a commit, different for each new commit. |
SELECTIVE_RUN_ATTEMPT | Yes | Increments each time the same run is retried from the CI provider. |
SELECTIVE_RUNNER_ID | Yes | Identifies the node, stable across runs and reruns. The parallel job index is the usual choice. |
SELECTIVE_BRANCH | Yes | The branch being built. |
SELECTIVE_SHA | Yes | The commit at the head of the build. |
SELECTIVE_GIT_REPO | Yes | owner/repo slug. |
SELECTIVE_GIT_PROVIDER | Yes | github, gitlab or bitbucket. |
SELECTIVE_BASE_SHA | No | The commit the change is compared against. Without it Selective compares against SELECTIVE_TARGET_BRANCH, or just the head commit if neither is set. |
SELECTIVE_TARGET_BRANCH | No | The branch the change will merge into, for example main. Used for ordering and selection. |
SELECTIVE_PR_TITLE | No | Shown in the dashboard. |
SELECTIVE_ACTOR | No | Who pushed. Shown in the dashboard. |
Then swap the test command as usual:
bundle exec selective rspecGetting the identifiers right
Section titled “Getting the identifiers right”- Run id and attempt together let Selective tell “someone clicked retry” apart from “a new commit was pushed”. Retries of a run share results with the earlier attempt; new commits start fresh.
- Runner id must not change when a job is retried, or Selective will think a new node joined. Avoid random values and hostnames that change between retries.
- Base sha or target branch is what makes test ordering and test selection work. Without either, Selective can still distribute and retry, but it only knows about the head commit.
Daily map recording
Section titled “Daily map recording”Use your provider’s scheduler to run the test job once a day on the default branch with SELECTIVE_TEST_MAP_RECORD=1 set. See keeping the map fresh.
Warm-up
Section titled “Warm-up”As the pipeline starts, from a job the tests don’t wait on, send the same values the test job sets:
curl -sS --max-time 20 -X POST https://app.selective.ci/warmup \ -H "authorization: $SELECTIVE_API_KEY" -H "content-type: application/json" \ -d "{\"sha\": \"$SELECTIVE_SHA\", \"git_repo_full_name\": \"$SELECTIVE_GIT_REPO\", \"base_sha\": \"$SELECTIVE_BASE_SHA\", \"target_branch\": \"$SELECTIVE_TARGET_BRANCH\", \"branch\": \"$SELECTIVE_BRANCH\"}" \ || trueSee warm-up.