Environment variables
The host and CI variables (BITBUCKET_*, GITHUB_*, CI) are resolved in one place —
utils/env.mjs — and task scripts import the semantic exports; a consumer variable such as
TEST_LEVEL is read by the command that owns it. Set the
consumer-facing ones as repository variables unless noted otherwise. The term covers the
host's CI variable store: a Bitbucket repository variable (secured for credentials), a GitHub Actions
variable or secret.
How booleans are parsed
Toggles accept 1, true, or yes (case-insensitive) as "on"; everything else, including
unset, 0, false, no, means "off". Scripts always write the canonical true.
Authentication
| Variable | Effect |
|---|---|
<ENV>_AUTH_URL |
SFDX auth URL for a stage org, e.g. SIT_AUTH_URL, UAT_AUTH_URL, PRODUCTION_AUTH_URL. |
DEVHUB_AUTH_URL |
SFDX auth URL for the DevHub (pooling, scratch orgs). |
BITBUCKET_ACCESS_TOKEN |
Repository access token for the Bitbucket REST calls that publish commit build statuses. On GitHub Actions the workflow token (GITHUB_TOKEN, granted statuses: write by the workflow) takes this role; nothing to set. |
Delta and validation opt-ins
| Variable | Effect |
|---|---|
DELTA_DEPLOY_<NAME> |
Enable delta deploys when <NAME> is the run's deployment environment or PR target branch (last segment, uppercased); the source branch is not matched. DELTA_DEPLOY_SCRATCH enables pooled-delta validation. |
DELTA_STAGE |
A step self-names its stage for exclusive matching (scratch-create sets SCRATCH). |
DELTA_TEST_LEVEL |
Test level of a delta run: RunRelevantTests (default) or any deploy test level, resolved like a full deploy (RunSpecifiedTestSuites uses the run's --test-suite-names; --tests apply). Any other value fails the run. |
SCRATCH_ORG_VALIDATION_<NAME> |
Opt a stage into pooled scratch-org validation for its PRs. |
DISABLE_SCRATCH_ORG_VALIDATION |
Global kill switch for the scratch-validation step — wins over everything. |
SCRATCH_ORG_VALIDATION_SKIP_WITHOUT_METADATA |
Skip scratch validation for PRs touching neither force-app nor .forceignore. |
Deploy behaviour
| Variable | Effect |
|---|---|
SF_DEPLOY_ENABLED |
Must be truthy in CI, or deploy exits 0 right after parsing its arguments (a dry run that prepares nothing). |
SF_DEPLOY_TARGET |
Drives replaceWhenEnv value replacements in sfdx-project.json (see how to replace a value per environment); defaults to ENVIRONMENT, else the configured pull-request fallback stage (SIT by default). |
TEST_LEVEL |
Apex test level for full deploys (default RunLocalTests). See how to control which Apex tests run on a full deploy. |
TESTS |
Space-separated Apex classes for RunSpecifiedTests. |
TEST_SUITE_NAMES |
Suite name(s) for RunSpecifiedTestSuites (converted to a class list). |
SF_ORG_METADATA_REST_DEPLOY |
Read by the sf CLI, not by the scripts: true switches sf project deploy from SOAP to the REST Metadata API. Required once a full package exceeds the SOAP request cap of 50 MB (error soapenv:Client: Maximum size of request reached); scratch-org pushes set it themselves. |
DEBUG |
Verbose output across the scripts (also -D/--debug per command). The only debug variable. |
Other pipeline inputs
| Variable | Effect |
|---|---|
PoolTag |
Bitbucket pipeline variable naming the pool a Maintain/Cleanup run acts on (passed as --tag); the GitHub workflows take the pool-tag input instead. |
BASE64_BOT_PRIVATE_KEY |
Base64 SSH private key the git bot uses to push back (ci auth-gitbot). Required on Bitbucket. Optional on GitHub: when set, the push goes over SSH with the bot key (what a protected write-back branch requires), otherwise the workflow token pushes. |
PACKAGE_ALIAS |
Default package for package-version-create when no --package-alias is given. |
Derived values (not set by you)
ENVIRONMENT (the stage, e.g. SIT/UAT/PRODUCTION, from the pipeline's deployment environment
or the PR target branch) and SF_DEPLOY_TARGET are computed in utils/env.mjs. The pipeline
context is read there too and exposed as semantic exports, from whichever provider runs the job:
BITBUCKET_* (BITBUCKET_COMMIT, BITBUCKET_PR_DESTINATION_BRANCH, BITBUCKET_BRANCH,
BITBUCKET_DEPLOYMENT_ENVIRONMENT, …) on Bitbucket Pipelines, GITHUB_* (GITHUB_SHA or the PR
head SHA, GITHUB_BASE_REF, GITHUB_HEAD_REF/GITHUB_REF_NAME, GITHUB_RUN_ID, …) plus the
generic DEPLOYMENT_ENVIRONMENT a job sets on GitHub Actions. CI_PROVIDER names the provider
(bitbucket, github, or empty locally). Why the reads are confined to that one module:
the shared library.
GitHub Actions: variables and secrets arrive as JSON
GitHub does not expose repository variables and secrets as environment variables. The reusable
workflows pass them as the job env CI_VARIABLES: ${{ toJSON(vars) }} and
CI_SECRETS: ${{ toJSON(secrets) }}; utils/env.mjs copies every key that is not already set
into the environment before anything else reads it, so the variable names above are the same
on both providers. The workflow token arrives as github_token and is mapped to GITHUB_TOKEN.
Branch map configuration
branchToDeploymentEnvironment() maps a branch to its environment name from
plugins.diadx.branchEnvironments in sfdx-project.json; pullRequestFallbackEnvironment names
the stage that pull requests into unmapped branches validate against. The template declares
integration and develop → sit, uat → uat, master, main and trunk → production,
fallback sit; utils/env.mjs falls back to the same values when the keys are absent. A repository
with other branch names edits the map:
"plugins": {
"diadx": {
"branchEnvironments": { "develop": "dev", "test": "test", "main": "production" },
"pullRequestFallbackEnvironment": "dev"
}
}
Matching is exact on the branch name. The environment name is at the same time the auth-URL
prefix (DEV_AUTH_URL), the sf alias, and the <NAME> of the DELTA_DEPLOY_<NAME> /
SCRATCH_ORG_VALIDATION_<NAME> opt-ins.
Set by the toolchain or the host
| Variable | Effect |
|---|---|
SCRIPTS_PRE_COMMIT |
Set by .husky/pre-commit; validate, format, the lint and the JavaScript test commands then skip the work lint-staged already did. |
SCRIPTS_VALIDATION |
Set by validate for the scripts it runs; test then skips the Apex tests. |
SILENT_MODE |
Quiets the progress output of org scratch-create. |
SCRATCH_ORG_NAME |
The org ci teardown deletes. |
GITHUB_STEP_SUMMARY, GITHUB_API_URL |
Provided by GitHub Actions: where ci github-test-summary writes, and the API base the commit-status provider calls. |
Exit-code conventions
| Code | Meaning |
|---|---|
| 0 | Success (or a dry run where SF_DEPLOY_ENABLED was not set). |
| 1 | Generic failure. |
| 2 | Usage error of org pool-release. |
| 4 | Configuration / definition error (bad pool def, unknown plugin, missing required file). |
| 21 | Deterministic Apex-test-only failure — the deploy will not be retried. See the delta ladder. |
| 42 | package-version-create / package-version-install: no package alias or no version selector. |
| 130 | Interrupted (SIGINT) during deploy or org scratch-create. |