Builtin variables
Varlock provides a set of builtin VARLOCK_* variables that are automatically populated with information about the current CI/deploy platform, git branch, commit, and inferred deployment environment. They are entirely opt-in — they only exist in your schema when you reference them.
Builtin variables are activated when you reference them via $VARLOCK_* in a value expression:
# @currentEnv=$VARLOCK_ENV# ---BUILD_TAG="build-$VARLOCK_COMMIT_SHA_SHORT"DB_URL=if( eq($VARLOCK_ENV, development), postgres://localhost/myapp, postgres://${VARLOCK_ENV}-db.example.com/myapp)If you want to include a builtin variable in your resolved env without referencing it from another item, just define it with an empty value — varlock will populate it automatically:
VARLOCK_BRANCH=VARLOCK_COMMIT_SHA_SHORT=You can also use VARLOCK_ENV as your environment flag with @currentEnv, which means you don’t need to create your own APP_ENV variable — Varlock will auto-detect the environment for you.
Builtin Vars
Section titled “Builtin Vars”VARLOCK_ENV
Section titled “VARLOCK_ENV”Type: string — one of development, preview, staging, production, test
The inferred deployment environment. Detection follows this priority:
- Test environment — detected from
NODE_ENV=test,VITEST,JEST_WORKER_ID, orVITEST_POOL_ID - Platform-provided — uses the platform’s own environment concept (e.g., Vercel’s
VERCEL_ENV, Netlify’sCONTEXT) - Branch inference — in CI, infers from branch name:
main/master/production/prod→production,staging/stage/develop/dev→staging,qa/test→test, anything else →preview - CI fallback — if in CI but no branch info is available, defaults to
preview - Local fallback — if not in CI, defaults to
development
Using with @currentEnv
Section titled “Using with @currentEnv”# @currentEnv=$VARLOCK_ENV# ---DB_HOST=if(forEnv(production), "prod-db.example.com", "localhost")DB_NAME=myappDB_URL="postgres://$DB_HOST/$DB_NAME"Test environment caveat
Section titled “Test environment caveat”VARLOCK_IS_CI
Section titled “VARLOCK_IS_CI”Type: string — "true" or "false"
Whether the current process is running in a CI environment.
VARLOCK_BRANCH
Section titled “VARLOCK_BRANCH”Type: string | undefined
The current git branch name, as reported by the CI platform. Undefined when not in CI or when the platform doesn’t expose branch info.
VARLOCK_PR_NUMBER
Section titled “VARLOCK_PR_NUMBER”Type: string | undefined
The pull/merge request number, if the current build is for a PR. Undefined otherwise.
VARLOCK_COMMIT_SHA
Section titled “VARLOCK_COMMIT_SHA”Type: string | undefined
The full git commit SHA.
VARLOCK_COMMIT_SHA_SHORT
Section titled “VARLOCK_COMMIT_SHA_SHORT”Type: string | undefined
The short (7-character) git commit SHA.
VARLOCK_PLATFORM
Section titled “VARLOCK_PLATFORM”Type: string | undefined
The name of the detected CI/deploy platform (e.g., "GitHub Actions", "Vercel", "Netlify CI").
VARLOCK_BUILD_URL
Section titled “VARLOCK_BUILD_URL”Type: string | undefined
A URL linking to the current build or deploy in the CI platform’s UI.
VARLOCK_REPO
Section titled “VARLOCK_REPO”Type: string | undefined
The repository name in owner/repo format.
Supported platforms
Section titled “Supported platforms”Detection is built-in for these platforms (no configuration required):
- GitHub Actions
- GitLab CI
- Vercel
- Netlify
- Cloudflare Pages / Workers
- AWS CodeBuild
- Azure Pipelines
- Bitbucket Pipelines
- Buildkite
- CircleCI
- Jenkins
- Render
- Travis CI
- and many more
Not all platforms expose all fields. For example, some may not provide branch name or PR number.
CI/deploy platform detection is powered by @varlock/ci-env-info, which can also be used as a standalone package.