This topic describes the Harness CI built-in environment variables. These variables contain information about the build, such as how the build started, codebase information, build infrastructure, step identifiers, and more. These are pipeline variables, and they are available to all stages and steps in the pipeline.
Reference environment variables
You can reference Harness CI environment variables through:
- Direct reference in shell commands, when available, such as
- Equivalent Harness expressions, such as
HARNESS_BUILD_ID, or many of the CI codebase expressions.
The value of environment variables depends on the build conditions. A variable is resolved only if the build includes the necessary information for that variable.
Manual builds occur when you manually run a pipeline from within Harness. You can select a branch, PR, or tag to build.
- Manual branch builds: Manually run a pipeline and select the Git Branch build type. Harness looks for the source code attached to the specified Branch Name, and it clones that specific source code for the build.
- Manual pull request (PR) builds: Manually run a pipeline and select the Git Pull Request build type. Harness looks for the source code attached to the specified Pull Request Number, and it clones that specific source code for the build.
- Manual tag builds: Manually run a pipeline and select the Git Tag build type. Harness looks for the source code attached to the specified Tag Name, and it clones that specific source code for the build.
- Pull request (PR) triggers: A Pull Request Webhook Event automatically starts a build in Harness when there is a new pull request event on the pipeline's associated Git repo. You can specify the type of pull request events to track, such as close, open, update/edit, reopen, and so on.
- Push triggers: A Push Webhook Event automatically starts a build in Harness when there is a new branch or tag push event on the pipeline's associated Git repo.
Lite-engine environment variables
These variables are related to the lite-engine service.
/harness, which is the default workspace. This is where Harness clones the codebase, and it is the working directory for all steps in a stage.
For descriptions of these and other identifier variables, go to Identifiers and status variables.
HARNESS_STO_SERVICE_ENDPOINT: The URL for STO service.
HARNESS_STO_SERVICE_TOKEN: Authentication for the STO service.
HARNESS_TI_SERVICE_ENDPOINT: The URL for Test Intelligence service.
HARNESS_TI_SERVICE_TOKEN: Authentication for the Test Intelligence service.
Other lite-engine variables
Identifier and status variables
These variables provide identifiers, statuses, and other references for pipelines, builds, stages, and steps.
For commit SHAs and other codebase-related identifiers, go to the CI codebase variables reference.
Your Harness account ID. Equivalent to
The incremental build ID for pipeline runs. This value is immutable. Equivalent to the expression
A pipeline's immutable UUID. Equivalent to
Your Harness organization ID. Equivalent to
A pipeline's identifier, usually based on the pipeline's name. Equivalent to
The Harness project ID. Equivalent to
The identifier for a stage. Equivalent to
ID of the user that started the build.
VERSION: Build infrastructure platform details.
HARNESS_INFRA: Build infrastructure type.
Matrix strategy variables
These variables track matrix strategies.
HARNESS_NODE_INDEX: Provides the index of a parallel run within a matrix strategy. Ranges from
HARNESS_NODE_TOTAL: Provides the total number of elements in a matrix strategy. Equivalent to the value of
parallelismin the pipeline's YAML.
HARNESS_STAGE_INDEX: Matrix index within a stage.
HARNESS_STAGE_TOTAL: Total elements in a matrix within a stage.
HARNESS_STEP_INDEX: Matrix index within a step.
HARNESS_STEP_TOTAL: Total elements in a matrix within a step.
Other environment variables might existing in your pipelines depending on the steps you use and other configurations, for example:
PLUGIN_ARTIFACT_FILE: Harness uses this to show links on the Artifacts tab.