Skip to main content

CI Environment Variables

v1.0.0

Predefined environment variables for GitHub Actions, GitLab CI, Jenkins, Azure Pipelines, and CircleCI.

26 entries found

GITHUB_SHAGitHub Actions

The commit SHA that triggered the workflow.

echo $GITHUB_SHA  # e.g. ffac537e6cbbf934b08745a378932722df287a53

Equivalent on other platforms:

gitlab: CI_COMMIT_SHAjenkins: GIT_COMMITazure: Build.SourceVersioncircleci: CIRCLE_SHA1
GITHUB_REFGitHub Actions

The fully-formed ref that triggered the workflow (refs/heads/main, refs/tags/v1.0.0, etc.).

echo $GITHUB_REF  # refs/heads/main

Equivalent on other platforms:

gitlab: CI_COMMIT_REF_NAMEjenkins: GIT_BRANCHazure: Build.SourceBranchcircleci: CIRCLE_BRANCH
GITHUB_REPOSITORYGitHub Actions

The owner and repository name in the format owner/repo.

echo $GITHUB_REPOSITORY  # myorg/myrepo

Equivalent on other platforms:

gitlab: CI_PROJECT_PATHazure: Build.Repository.Name
GITHUB_WORKSPACEGitHub Actions

The absolute path of the checked-out repository on the runner.

ls $GITHUB_WORKSPACE

Equivalent on other platforms:

gitlab: CI_PROJECT_DIRjenkins: WORKSPACEazure: Build.SourcesDirectorycircleci: CIRCLE_WORKING_DIRECTORY
GITHUB_RUN_NUMBERGitHub Actions

A unique sequential number for each workflow run in the repository. Starts at 1.

echo "Build #$GITHUB_RUN_NUMBER"

Equivalent on other platforms:

gitlab: CI_PIPELINE_IIDjenkins: BUILD_NUMBERazure: Build.BuildIdcircleci: CIRCLE_BUILD_NUM
GITHUB_TOKENGitHub Actions

Automatically-created token for authenticating within the workflow. Scoped to the repository.

curl -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/...

Equivalent on other platforms:

gitlab: CI_JOB_TOKEN
GITHUB_ACTORGitHub Actions

The username of the user or app that triggered the workflow run.

echo "Triggered by $GITHUB_ACTOR"

Equivalent on other platforms:

gitlab: GITLAB_USER_LOGIN
GITHUB_EVENT_NAMEGitHub Actions

The name of the event that triggered the workflow (push, pull_request, workflow_dispatch, etc.).

if [ "$GITHUB_EVENT_NAME" = "push" ]; then ./deploy.sh; fi
CI_COMMIT_SHAGitLab CI

The full commit SHA for the current pipeline.

echo $CI_COMMIT_SHA

Equivalent on other platforms:

github: GITHUB_SHAjenkins: GIT_COMMITazure: Build.SourceVersioncircleci: CIRCLE_SHA1
CI_COMMIT_REF_NAMEGitLab CI

The branch or tag name for which the project is built.

echo $CI_COMMIT_REF_NAME  # main

Equivalent on other platforms:

github: GITHUB_REFjenkins: GIT_BRANCHazure: Build.SourceBranchName
CI_PROJECT_NAMEGitLab CI

The name of the directory for the project. This is the last part of CI_PROJECT_PATH.

echo $CI_PROJECT_NAME

Equivalent on other platforms:

github: GITHUB_REPOSITORYjenkins: JOB_NAME
CI_PIPELINE_IDGitLab CI

The globally unique ID of the current pipeline.

echo "Pipeline $CI_PIPELINE_ID"
CI_JOB_TOKENGitLab CI

Token to authenticate with the GitLab API and container registry from within a job.

docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY

Equivalent on other platforms:

github: GITHUB_TOKEN
CI_REGISTRY_IMAGEGitLab CI

The full URL of the project's container registry image.

docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
BUILD_NUMBERJenkins

The current build number (sequential integer, e.g. 42).

echo "Build #$BUILD_NUMBER"

Equivalent on other platforms:

github: GITHUB_RUN_NUMBERgitlab: CI_PIPELINE_IIDazure: Build.BuildId
JOB_NAMEJenkins

Name of the project/job for the current build.

echo $JOB_NAME
WORKSPACEJenkins

Absolute path of the workspace directory.

ls $WORKSPACE

Equivalent on other platforms:

github: GITHUB_WORKSPACEgitlab: CI_PROJECT_DIRazure: Build.SourcesDirectory
BUILD_URLJenkins

Full URL of the current build result page.

echo "View at $BUILD_URL"
Build.BuildIdAzure Pipelines

The ID of the current build (unique within the project).

echo $(Build.BuildId)

Equivalent on other platforms:

github: GITHUB_RUN_NUMBERgitlab: CI_PIPELINE_IIDjenkins: BUILD_NUMBER
Build.SourceBranchNameAzure Pipelines

The last path segment of the triggering branch (e.g. main, not refs/heads/main).

echo $(Build.SourceBranchName)

Equivalent on other platforms:

github: GITHUB_REFgitlab: CI_COMMIT_REF_NAMEjenkins: GIT_BRANCH
Build.SourceVersionAzure Pipelines

The latest version control change that was included in the build (commit SHA).

echo $(Build.SourceVersion)

Equivalent on other platforms:

github: GITHUB_SHAgitlab: CI_COMMIT_SHAjenkins: GIT_COMMIT
Agent.OSAzure Pipelines

The operating system of the agent (Windows_NT, Linux, Darwin).

- script: echo $(Agent.OS)
CIRCLE_SHA1CircleCI

SHA1 hash of the last commit of the current build.

echo $CIRCLE_SHA1

Equivalent on other platforms:

github: GITHUB_SHAgitlab: CI_COMMIT_SHAjenkins: GIT_COMMITazure: Build.SourceVersion
CIRCLE_BRANCHCircleCI

The name of the Git branch currently being built.

echo $CIRCLE_BRANCH

Equivalent on other platforms:

github: GITHUB_REFgitlab: CI_COMMIT_REF_NAMEjenkins: GIT_BRANCH
CIRCLE_PROJECT_REPONAMECircleCI

The name of the repository of the current project.

echo $CIRCLE_PROJECT_REPONAME
CIRCLE_BUILD_NUMCircleCI

The number of the CircleCI build.

echo "Build #$CIRCLE_BUILD_NUM"

Equivalent on other platforms:

github: GITHUB_RUN_NUMBERgitlab: CI_PIPELINE_IIDjenkins: BUILD_NUMBER