Skip to content

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.

VariableRequiredWhat it is
SELECTIVE_API_KEYYesThe suite’s API key from the dashboard.
SELECTIVE_PLATFORMYesA short name for your CI, for example jenkins or gitlab. Shown in the dashboard.
SELECTIVE_RUN_IDYesIdentifies one run of the suite. Same across reruns of a commit, different for each new commit.
SELECTIVE_RUN_ATTEMPTYesIncrements each time the same run is retried from the CI provider.
SELECTIVE_RUNNER_IDYesIdentifies the node, stable across runs and reruns. The parallel job index is the usual choice.
SELECTIVE_BRANCHYesThe branch being built.
SELECTIVE_SHAYesThe commit at the head of the build.
SELECTIVE_GIT_REPOYesowner/repo slug.
SELECTIVE_GIT_PROVIDERYesgithub, gitlab or bitbucket.
SELECTIVE_BASE_SHANoThe 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_BRANCHNoThe branch the change will merge into, for example main. Used for ordering and selection.
SELECTIVE_PR_TITLENoShown in the dashboard.
SELECTIVE_ACTORNoWho pushed. Shown in the dashboard.

Then swap the test command as usual:

Terminal window
bundle exec selective rspec
  • 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.

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.

As the pipeline starts, from a job the tests don’t wait on, send the same values the test job sets:

Terminal window
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\"}" \
|| true

See warm-up.