Project values and variables
This page is a reference for all built-in values available for use in your CircleCI projects.
Built-in environment variables
The following built-in environment variables are available for CircleCI projects. Some environment variables are available for GitHub OAuth and Bitbucket Cloud projects that have been deprecated for GitLab, GitHub App and Bitbucket Data Center support. If you must continue to use those as environment variables in your GitLab pipelines, refer to the workaround described after the list below.
Environment variables are scoped at the job level and can be used within the context of a job. Environment variables do not exist at a pipeline level, therefore they cannot be used for any logic at the pipeline or workflow level.
You cannot use a built-in environment variable to define another environment variable. Instead, you must use a run step to export the new environment variables using BASH_ENV. For more details, see Setting an Environment Variable in a Shell Command.
|
| Variable | VCS | Type | Value | Cloud | Server |
|---|---|---|---|---|---|
|
GitHub, Bitbucket, GitLab |
Boolean |
|
||
|
GitHub, Bitbucket, GitLab |
Boolean |
|
||
|
GitHub, Bitbucket, GitLab |
String |
The name of the Git branch currently being built. |
||
|
GitHub, Bitbucket, GitLab |
Integer |
The number of the current job. Job numbers are unique for each job. |
||
|
GitHub, Bitbucket, GitLab |
String |
The URL for the current job on CircleCI. |
||
|
GitHub, Bitbucket, GitLab |
String |
The name of the current job. |
||
|
GitHub, Bitbucket, GitLab |
Integer |
For jobs that run with parallelism enabled, this is the index of the current parallel run. The value ranges from 0 to ( |
||
|
GitHub, Bitbucket, GitLab |
Integer |
For jobs that run with parallelism enabled, this is the number of parallel runs. This is equivalent to the value of |
||
|
GitHub, Bitbucket, GitLab |
String |
An OpenID Connect token signed by CircleCI which includes details about the current job. |
|
|
|
GitHub, Bitbucket, GitLab |
String |
An OpenID Connect token signed by CircleCI which includes details about the current job. |
|
|
|
GitHub, Bitbucket, GitLab |
String |
A unique identifier for the CircleCI organization. |
||
|
GitHub, Bitbucket, GitLab |
String |
A unique identifier for the current pipeline. |
||
|
GitHub OAuth, Bitbucket Cloud |
Integer |
The number of the associated GitHub or Bitbucket pull request. Only available on forked PRs. |
||
|
GitHub OAuth, Bitbucket Cloud |
String |
The name of the GitHub or Bitbucket repository where the pull request was created. Only available on forked PRs. |
||
|
GitHub OAuth, Bitbucket Cloud |
String |
The GitHub or Bitbucket username of the user who created the pull request. Only available on forked PRs. |
||
|
GitHub, Bitbucket, GitLab |
Integer |
The largest job number in a given branch that is less than the current job number. Note: The variable is not always set, and is not deterministic. It is also not set on runner executors. This variable will be deprecated and is not recommended for use. |
||
|
GitHub, Bitbucket, GitLab |
String |
A unique identifier for the current project. |
||
|
GitHub, GitLab, Bitbucket |
String |
The name of the repository of the current project. |
||
|
GitHub, GitLab, Bitbucket |
String |
The GitHub or Bitbucket username of the current project. |
||
|
GitHub, Bitbucket Cloud |
String |
The URL of the associated pull request. If there are multiple associated pull requests, one URL is randomly chosen. |
||
|
GitHub OAuth, Bitbucket Cloud |
List |
Comma-separated list of URLs of the current build’s associated pull requests. |
||
|
GitHub OAuth, Bitbucket Cloud |
String |
The URL of your GitHub or Bitbucket repository. |
||
|
GitHub, GitLab, Bitbucket |
String |
The SHA1 hash of the last commit of the current build. |
||
|
GitHub, Bitbucket, GitLab |
String |
The name of the git tag, if the current build is tagged. For more information, see the Git tag job execution section of the Workflows page. |
||
|
GitHub, Bitbucket, GitLab |
String |
The GitHub or Bitbucket username of the user who triggered the pipeline (only if the user has a CircleCI account). |
||
|
GitHub, Bitbucket, GitLab |
String |
A unique identifier for the workflow instance of the current job. This identifier is the same for every job in a given workflow instance. |
||
|
GitHub, Bitbucket, GitLab |
String |
A unique identifier for the current job. |
||
|
GitHub, Bitbucket, GitLab |
String |
An identifier for the workspace of the current job. This identifier is the same for every job in a given workflow. |
||
|
GitHub, Bitbucket, GitLab |
String |
The value of the |
||
|
GitHub, Bitbucket, GitLab |
String |
Internal. A directory where internal data related to the job is stored. We do not document the contents of this directory; the data schema is subject to change. |
If you must use the environment variables that are deprecated for GitLab SaaS in your GitLab pipelines, you can recreate this functionality using pipeline values in your configuration file. The following example shows how to set an environment variable CIRCLE_PROJECT_REPONAME using the environment key and populating it with the pipeline.trigger_parameters.gitlab.repo_name value:
build:
docker:
- image: cimg/node:17.0
auth:
username: mydockerhub-user
password: $DOCKERHUB_PASSWORD # context / project UI env-var reference
environment:
CIRCLE_PROJECT_REPONAME: << pipeline.trigger_parameters.gitlab.repo_name >>
steps:
- run: echo $CIRCLE_PROJECT_REPONAME
Pipeline values
Pipeline values are available to all pipeline configurations and can be used without previous declaration. Pipeline values are scoped at the pipeline level. They are interpolated at compilation time, not workflow/job runtime.
The pipeline values available to you depend on your pipeline/integration type, as shown in the "Source" column of the table below.
| Variable | Source | Type | Value | Cloud | Server |
|---|---|---|---|---|---|
|
GitHub App |
String |
A globally unique id representing for the pipeline. |
Yes |
Yes |
|
GitHub App |
Integer |
A project unique integer id for the pipeline. |
Yes |
Yes |
|
GitHub App |
String |
The unique ID of the pipeline definition. |
Yes |
Yes |
|
GitHub App |
String |
The file path to the CircleCI configuration file used by the pipeline. |
Yes |
No |
|
GitHub App |
String |
The full Git ref used to fetch the CircleCI configuration file, for example |
Yes |
No |
|
GitHub App |
String |
The name of the repository containing the CircleCI configuration file, in the format |
Yes |
No |
|
GitHub App |
String |
The URL of the repository containing the CircleCI configuration file. |
Yes |
No |
|
GitHub App |
String |
The long (40-character) git SHA of the commit used to fetch the CircleCI configuration file. |
Yes |
No |
|
GitHub App |
String |
The URL where the current project is hosted. For example, |
Yes |
Yes |
|
GitHub App |
String |
The lower-case name of the VCS provider, for example, |
Yes |
Yes |
|
GitHub App |
String |
The timestamp of when the pipeline was triggered, in ISO 8601 format. |
Yes |
Yes |
|
GitHub App |
String |
The name of the git tag that was pushed to trigger the pipeline. If the pipeline was not triggered by a tag, then this is the empty string. |
Yes |
Yes |
|
GitHub App |
String |
The name of the git branch that was pushed to trigger the pipeline. |
Yes |
Yes |
|
GitHub App |
Boolean |
Whether the branch the pipeline was triggered on is the default branch. |
Yes |
Yes (>= v4.7) |
|
GitHub App |
String |
The long (40-character) git SHA that is being built. |
Yes |
Yes |
|
GitHub OAuth |
String |
The long (40-character) git SHA of the build prior to the one being built. Note: While in most cases |
Yes |
Yes |
|
GitHub App |
String |
The source that triggers the pipeline, current values are |
Yes |
Yes |
|
GitHub OAuth |
String |
The name of the schedule trigger if the pipeline was triggered via schedule. The value will be empty string if the pipeline is triggered by other sources. |
Yes |
Yes |
|
GitHub OAuth |
String |
The unique ID of the schedule if the pipeline was triggered via schedule trigger. Value will be empty string if the pipeline is triggered by other sources. |
Yes |
Yes |
|
GitHub App |
String |
GitHub App, GitLab |
Yes |
No |
|
GitHub App |
String |
Timestamp CircleCI received the event |
Yes |
No |
|
GitHub App |
String |
GitHub App: push |
Yes |
No |
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
GitHub App |
See GitHub documentation for webhook events and payloads. |
Yes |
No |
|
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
GitHub App |
See GitHub documentation for webhook events and payloads. |
Yes |
No |
|
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
GitHub App |
See GitHub documentation for webhook events and payloads. |
Yes |
No |
|
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
GitHub App |
See GitHub documentation for webhook events and payloads. |
Yes |
No |
|
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
GitHub App |
See GitHub documentation for webhook events and payloads. |
Yes |
No |
|
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
GitHub App |
See GitHub documentation for webhook events and payloads. |
Yes |
No |
|
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
GitHub App |
See GitHub documentation for webhook events and payloads. |
Yes |
No |
|
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
GitHub App |
See GitHub documentation for webhook events and payloads. |
Yes |
No |
|
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
GitHub App |
See GitHub documentation for webhook events and payloads. |
Yes |
No |
|
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
GitHub App |
See GitHub documentation for webhook events and payloads. |
Yes |
No |
|
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
GitHub App |
See GitHub documentation for webhook events and payloads. |
Yes |
No |
|
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
GitHub App |
See GitHub documentation for webhook events and payloads. |
Yes |
No |
|
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
GitHub App |
See GitHub documentation for webhook events and payloads. |
Yes |
No |
|
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
GitHub App |
See GitHub documentation for webhook events and payloads. |
Yes |
No |
|
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
GitHub App |
See GitHub documentation for webhook events and payloads. |
Yes |
No |
|
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
GitLab |
See GitLab documentation for webhooks and webhook events. |
Yes |
No |
|
|
Custom webhook |
String |
The body of the payload that was sent with a Custom Webhook. |
Yes |
No |
|
GitHub App |
String |
The name of the event that triggered the pipeline. Possible values: |
Yes |
No |
|
GitHub App |
String |
The action associated with the event. This value is always the same as |
Yes |
No |
|
GitHub App |
String |
The SHA of the most recent commit on the branch after the push. Corresponds to the |
Yes |
No |
|
GitHub App |
String |
The URL of the most recent commit on the branch. Corresponds to the |
Yes |
No |
|
GitHub App |
String |
The full Git ref that was pushed. Corresponds to the |
Yes |
No |
|
GitHub App |
String |
The URL of the associated GitHub pull request, if one exists. If there are multiple associated pull requests, one URL is randomly chosen. This value matches environment variable CIRCLE_PULL_REQUEST. |
Yes |
No |
|
GitHub App |
String |
The name of the base (or target) branch of the pull request. Corresponds to the |
Yes |
No |
|
GitHub App |
String |
The SHA of the base branch of the pull request. Corresponds to the |
Yes |
No |
|
GitHub App |
String |
The name of the head branch of the pull request. Corresponds to the |
Yes |
No |
|
GitHub App |
String |
The SHA of the head branch of the pull request. Corresponds to the |
Yes |
No |
|
GitHub App |
Boolean |
A boolean value indicating whether the pull request is a draft. Corresponds to the |
Yes |
No |
|
GitHub App |
String |
The title of the pull request. Corresponds to the |
Yes |
No |
|
GitHub App |
Integer |
The numeric identifier of the pull request. Corresponds to the |
Yes |
No |
|
GitHub App |
Boolean |
A boolean value indicating whether the pull request has been merged. Corresponds to the |
Yes |
No |
|
GitHub App |
String |
The URL of the pull request. Corresponds to the |
Yes |
No |
|
GitHub App |
String |
The name of the label applied to the pull request. Corresponds to the |
Yes |
No |
|
GitHub App |
String |
The body of the comment that triggered the pipeline, with leading and trailing whitespace removed. Corresponds to the |
Yes |
No |
|
GitHub App |
String |
The type of GitHub user that triggered the event. Corresponds to the |
Yes |
No |
|
GitHub App |
String |
The avatar URL of the GitHub user who triggered the event. Corresponds to the |
Yes |
No |
|
GitHub App |
String |
The login name of the GitHub user who triggered the event. Corresponds to the |
Yes |
No |
|
GitHub App |
String |
The name of the repository that triggered the event, without the owner prefix. Corresponds to the |
Yes |
No |
|
GitHub App |
String |
The login name of the repository owner. Corresponds to the |
Yes |
No |
|
GitHub App |
String |
The URL of the repository that triggered the event. Corresponds to the |
Yes |
No |
|
GitHub App |
String |
The name of the component that will be rolled back or deployed. Only for use with rollbacks and deploys. See Set up a Rollback Pipeline and Set up a Deploy Pipeline guides. |
Yes |
No |
|
GitHub App |
String |
The name of the environment in which the rollback or deploy will be performed. Only for use with rollbacks and deploys. See Set up a Rollback Pipeline and Set up a Deploy Pipeline guides. |
Yes |
No |
|
GitHub App |
String |
The version of the component that needs to be rolled back to or deployed. Only for use with rollbacks and deploys. See Set up a Rollback Pipeline and Set up a Deploy Pipeline guides. |
Yes |
No |
|
GitHub App |
String |
The current version of the component that is going to be rolled back or deployed. Can be used to verify that the status of the component matches expectations. Only for use with rollbacks and deploys. See Set up a Rollback Pipeline and Set up a Deploy Pipeline guides. |
Yes |
No |
|
GitHub App |
String |
The namespace of the environment that was deployed to. Only for use with rollbacks and deploys. See Set up a Rollback Pipeline and Set up a Deploy Pipeline guides. |
Yes |
No |
|
GitHub App |
String |
The reason for the deployment or rollback. Only for use with rollbacks and deploys. See Set up a Rollback Pipeline and Set up a Deploy Pipeline guides. |
Yes |
No |
For example:
version: 2.1
jobs:
build:
docker:
- image: cimg/node:20.3.0
environment:
CIRCLE_COMPARE_URL: << pipeline.project.git_url >>/compare/<< pipeline.git.base_revision >>..<<pipeline.git.revision>>
working_directory: ~/main
steps:
- run: echo "This is pipeline ID << pipeline.id >>"
- run: echo $CIRCLE_COMPARE_URL
When using the above method to set the variables in the environment key, note that if the pipeline variable is empty it will be set to <nil>. If you need an empty string instead, set the variable in a shell command.