CI Environment Variables
v1.0.0Predefined environment variables for GitHub Actions, GitLab CI, Jenkins, Azure Pipelines, and CircleCI.
26 entries found
The commit SHA that triggered the workflow.
echo $GITHUB_SHA # e.g. ffac537e6cbbf934b08745a378932722df287a53
Equivalent on other platforms:
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:
The owner and repository name in the format owner/repo.
echo $GITHUB_REPOSITORY # myorg/myrepo
Equivalent on other platforms:
The absolute path of the checked-out repository on the runner.
ls $GITHUB_WORKSPACE
Equivalent on other platforms:
A unique sequential number for each workflow run in the repository. Starts at 1.
echo "Build #$GITHUB_RUN_NUMBER"
Equivalent on other platforms:
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:
The username of the user or app that triggered the workflow run.
echo "Triggered by $GITHUB_ACTOR"
Equivalent on other platforms:
The name of the event that triggered the workflow (push, pull_request, workflow_dispatch, etc.).
if [ "$GITHUB_EVENT_NAME" = "push" ]; then ./deploy.sh; fi
The full commit SHA for the current pipeline.
echo $CI_COMMIT_SHA
Equivalent on other platforms:
The branch or tag name for which the project is built.
echo $CI_COMMIT_REF_NAME # main
Equivalent on other platforms:
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:
The globally unique ID of the current pipeline.
echo "Pipeline $CI_PIPELINE_ID"
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:
The full URL of the project's container registry image.
docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
The current build number (sequential integer, e.g. 42).
echo "Build #$BUILD_NUMBER"
Equivalent on other platforms:
Name of the project/job for the current build.
echo $JOB_NAME
Absolute path of the workspace directory.
ls $WORKSPACE
Equivalent on other platforms:
Full URL of the current build result page.
echo "View at $BUILD_URL"
The ID of the current build (unique within the project).
echo $(Build.BuildId)
Equivalent on other platforms:
The last path segment of the triggering branch (e.g. main, not refs/heads/main).
echo $(Build.SourceBranchName)
Equivalent on other platforms:
The latest version control change that was included in the build (commit SHA).
echo $(Build.SourceVersion)
Equivalent on other platforms:
The operating system of the agent (Windows_NT, Linux, Darwin).
- script: echo $(Agent.OS)
SHA1 hash of the last commit of the current build.
echo $CIRCLE_SHA1
Equivalent on other platforms:
The name of the Git branch currently being built.
echo $CIRCLE_BRANCH
Equivalent on other platforms:
The name of the repository of the current project.
echo $CIRCLE_PROJECT_REPONAME
The number of the CircleCI build.
echo "Build #$CIRCLE_BUILD_NUM"
Equivalent on other platforms: