Skip to main content

CI environment variables reference

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:

Variable resolution

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

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.

Webhook triggers

You can automatically trigger pipelines using Git events. Webhook triggers listen for specific events in your code repo, and then trigger builds when those events occur.

  • 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_WORKSPACE

Always /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.

_ID variables

  • HARNESS_ACCOUNT_ID
  • HARNESS_BUILD_ID
  • HARNESS_EXECUTION_ID
  • HARNESS_ORG_ID
  • HARNESS_PIPELINE_ID
  • HARNESS_PROJECT_ID
  • HARNESS_STAGE_ID

For descriptions of these and other identifier variables, go to Identifiers and status variables.

_SERVICE_ variables

  • DELEGATE_SERVICE_TOKEN
  • DELEGATE_SERVICE_ENDPOINT
  • DELEGATE_SERVICE_ID
  • HARNESS_LOG_SERVICE_ENDPOINT
  • HARNESS_LOG_SERVICE_TOKEN
  • 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

  • HARNESS_LOG_PREFIX
  • HARNESS_SECRETS_LIST

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.

HARNESS_ACCOUNT_ID

Your Harness account ID. Equivalent to <+account.identifier>.

HARNESS_BUILD_ID

The incremental build ID for pipeline runs. This value is immutable. Equivalent to the expression <+pipeline.sequenceId>.

HARNESS_DELEGATE_ID

Delegate identifier.

HARNESS_EXECUTION_ID

A pipeline's immutable UUID. Equivalent to <pipeline.executionId>.

HARNESS_ORG_ID

Your Harness organization ID. Equivalent to <+org.identifier>.

HARNESS_PIPELINE_ID

A pipeline's identifier, usually based on the pipeline's name. Equivalent to <+pipeline.identifier>.

HARNESS_PROJECT_ID

The Harness project ID. Equivalent to <+project.identifier>.

HARNESS_STAGE_ID

The identifier for a stage. Equivalent to <+stage.identifier>.

HARNESS_USER_ID

ID of the user that started the build.

Infrastructure variables

  • PLATFORM and 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 0 to parallelism -1.
  • HARNESS_NODE_TOTAL: Provides the total number of elements in a matrix strategy. Equivalent to the value of parallelism in 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 variables

Other environment variables might existing in your pipelines depending on the steps you use and other configurations, for example:

  • JDK
  • JFROG_PASSWORD
  • JFROG_USERNAME
  • PLUGIN_ARTIFACT_FILE
  • PLUGIN_PIPELINE
  • GCP_BAZEL_CACHE_CRED_PATH
  • GCP_KEY
  • BUILD_PURPOSE
  • DRONE_NETRC_MACHINE