Predefined variables reference

Predefined CI/CD variables are available in every GitLab CI/CD pipeline.

Some variables are only available with more recent versions of GitLab Runner.

You can output the values of all variables available for a job with a script command.

There are also a number of variables you can use to configure runner behavior globally or for individual jobs.

note
You should avoid overriding predefined variables, as it can cause the pipeline to behave unexpectedly.
VariableGitLabRunnerDescription
CHAT_CHANNEL10.6allThe Source chat channel that triggered the ChatOps command.
CHAT_INPUT10.6allThe additional arguments passed with the ChatOps command.
CHAT_USER_ID14.4allThe chat service’s user ID of the user who triggered the ChatOps command.
CIall0.4Available for all jobs executed in CI/CD. true when available.
CI_API_V4_URL11.7allThe GitLab API v4 root URL.
CI_API_GRAPHQL_URL15.11allThe GitLab API GraphQL root URL.
CI_BUILDS_DIRall11.10The top-level directory where builds are executed.
CI_COMMIT_AUTHOR13.11allThe author of the commit in Name <email> format.
CI_COMMIT_BEFORE_SHA11.2allThe previous latest commit present on a branch or tag. Is always 0000000000000000000000000000000000000000 in merge request pipelines and for the first commit in pipelines for branches or tags.
CI_COMMIT_BRANCH12.60.5The commit branch name. Available in branch pipelines, including pipelines for the default branch. Not available in merge request pipelines or tag pipelines.
CI_COMMIT_DESCRIPTION10.8allThe description of the commit. If the title is shorter than 100 characters, the message without the first line.
CI_COMMIT_MESSAGE10.8allThe full commit message.
CI_COMMIT_REF_NAME9.0allThe branch or tag name for which project is built.
CI_COMMIT_REF_PROTECTED11.11all true if the job is running for a protected reference, false otherwise.
CI_COMMIT_REF_SLUG9.0all CI_COMMIT_REF_NAME in lowercase, shortened to 63 bytes, and with everything except 0-9 and a-z replaced with -. No leading / trailing -. Use in URLs, host names and domain names.
CI_COMMIT_SHA9.0allThe commit revision the project is built for.
CI_COMMIT_SHORT_SHA11.7allThe first eight characters of CI_COMMIT_SHA.
CI_COMMIT_TAG9.00.5The commit tag name. Available only in pipelines for tags.
CI_COMMIT_TAG_MESSAGE15.5allThe commit tag message. Available only in pipelines for tags.
CI_COMMIT_TIMESTAMP13.4allThe timestamp of the commit in the ISO 8601 format.
CI_COMMIT_TITLE10.8allThe title of the commit. The full first line of the message.
CI_CONCURRENT_IDall11.10The unique ID of build execution in a single executor.
CI_CONCURRENT_PROJECT_IDall11.10The unique ID of build execution in a single executor and project.
CI_CONFIG_PATH9.40.5The path to the CI/CD configuration file. Defaults to .gitlab-ci.yml. Read-only inside a running pipeline.
CI_DEBUG_TRACEall1.7 true if debug logging (tracing) is enabled.
CI_DEBUG_SERVICES15.715.7 true if service container logging is enabled.
CI_DEFAULT_BRANCH12.4allThe name of the project’s default branch.
CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX13.7allThe top-level group image prefix for pulling images through the Dependency Proxy.
CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX14.3allThe direct group image prefix for pulling images through the Dependency Proxy.
CI_DEPENDENCY_PROXY_PASSWORD13.7allThe password to pull images through the Dependency Proxy.
CI_DEPENDENCY_PROXY_SERVER13.7allThe server for logging in to the Dependency Proxy. This is equivalent to $CI_SERVER_HOST:$CI_SERVER_PORT.
CI_DEPENDENCY_PROXY_USER13.7allThe username to pull images through the Dependency Proxy.
CI_DEPLOY_FREEZE13.2allOnly available if the pipeline runs during a deploy freeze window. true when available.
CI_DEPLOY_PASSWORD10.8allThe authentication password of the GitLab Deploy Token, if the project has one.
CI_DEPLOY_USER10.8allThe authentication username of the GitLab Deploy Token, if the project has one.
CI_DISPOSABLE_ENVIRONMENTall10.1Only available if the job is executed in a disposable environment (something that is created only for this job and disposed of/destroyed after the execution - all executors except shell and ssh). true when available.
CI_ENVIRONMENT_NAME8.15allThe name of the environment for this job. Available if environment:name is set.
CI_ENVIRONMENT_SLUG8.15allThe simplified version of the environment name, suitable for inclusion in DNS, URLs, Kubernetes labels, and so on. Available if environment:name is set. The slug is truncated to 24 characters. A random suffix is automatically added to uppercase environment names.
CI_ENVIRONMENT_URL9.3allThe URL of the environment for this job. Available if environment:url is set.
CI_ENVIRONMENT_ACTION13.11allThe action annotation specified for this job’s environment. Available if environment:action is set. Can be start, prepare, or stop.
CI_ENVIRONMENT_TIER14.0allThe deployment tier of the environment for this job.
CI_RELEASE_DESCRIPTION15.5allThe description of the release. Available only on pipelines for tags. Description length is limited to first 1024 characters.
CI_GITLAB_FIPS_MODE14.10allOnly available if FIPS mode is enabled in the GitLab instance. true when available.
CI_HAS_OPEN_REQUIREMENTS13.1allOnly available if the pipeline’s project has an open requirement. true when available.
CI_JOB_ID9.0allThe internal ID of the job, unique across all jobs in the GitLab instance.
CI_JOB_IMAGE12.912.9The name of the Docker image running the job.
CI_JOB_JWT (Deprecated)12.10allA RS256 JSON web token to authenticate with third party systems that support JWT authentication, for example HashiCorp’s Vault. Deprecated in GitLab 15.9 and scheduled to be removed in GitLab 17.0. Use ID tokens instead.
CI_JOB_JWT_V1 (Deprecated)14.6allThe same value as CI_JOB_JWT. Deprecated in GitLab 15.9 and scheduled to be removed in GitLab 17.0. Use ID tokens instead.
CI_JOB_JWT_V2 (Deprecated)14.6allA newly formatted RS256 JSON web token to increase compatibility. Similar to CI_JOB_JWT, except the issuer (iss) claim is changed from gitlab.com to https://gitlab.com, sub has changed from job_id to a string that contains the project path, and an aud claim is added. The aud field is a constant value. Trusting JWTs in multiple relying parties can lead to one RP sending a JWT to another one and acting maliciously as a job. Deprecated in GitLab 15.9 and scheduled to be removed in GitLab 17.0. Use ID tokens instead.
CI_JOB_MANUAL8.12allOnly available if the job was started manually. true when available.
CI_JOB_NAME9.00.5The name of the job.
CI_JOB_NAME_SLUG15.4all CI_JOB_NAME_SLUG in lowercase, shortened to 63 bytes, and with everything except 0-9 and a-z replaced with -. No leading / trailing -. Use in paths.
CI_JOB_STAGE9.00.5The name of the job’s stage.
CI_JOB_STATUSall13.5The status of the job as each runner stage is executed. Use with after_script. Can be success, failed, or canceled.
CI_JOB_TIMEOUT15.715.7The job timeout, in seconds.
CI_JOB_TOKEN9.01.2A token to authenticate with certain API endpoints. The token is valid as long as the job is running.
CI_JOB_URL11.10.5The job details URL.
CI_JOB_STARTED_AT13.10allThe UTC datetime when a job started, in ISO 8601 format.
CI_KUBERNETES_ACTIVE13.0allOnly available if the pipeline has a Kubernetes cluster available for deployments. true when available.
CI_NODE_INDEX11.5allThe index of the job in the job set. Only available if the job uses parallel.
CI_NODE_TOTAL11.5allThe total number of instances of this job running in parallel. Set to 1 if the job does not use parallel.
CI_OPEN_MERGE_REQUESTS13.8allA comma-separated list of up to four merge requests that use the current branch and project as the merge request source. Only available in branch and merge request pipelines if the branch has an associated merge request. For example, gitlab-org/gitlab!333,gitlab-org/gitlab-foss!11.
CI_PAGES_DOMAIN11.8allThe configured domain that hosts GitLab Pages.
CI_PAGES_URL11.8allThe URL for a GitLab Pages site. Always a subdomain of CI_PAGES_DOMAIN.
CI_PIPELINE_ID8.10allThe instance-level ID of the current pipeline. This ID is unique across all projects on the GitLab instance.
CI_PIPELINE_IID11.0allThe project-level IID (internal ID) of the current pipeline. This ID is unique only within the current project.
CI_PIPELINE_SOURCE10.0allHow the pipeline was triggered. Can be push, web, schedule, api, external, chat, webide, merge_request_event, external_pull_request_event, parent_pipeline, trigger, or pipeline. For a description of each value, see Common if clauses for rules, which uses this variable to control when jobs run.
CI_PIPELINE_TRIGGEREDallall true if the job was triggered.
CI_PIPELINE_URL11.10.5The URL for the pipeline details.
CI_PIPELINE_CREATED_AT13.10allThe UTC datetime when the pipeline was created, in ISO 8601 format.
CI_PIPELINE_NAME16.3allThe pipeline name defined in workflow:name
CI_PROJECT_DIRallallThe full path the repository is cloned to, and where the job runs from. If the GitLab Runner builds_dir parameter is set, this variable is set relative to the value of builds_dir. For more information, see the Advanced GitLab Runner configuration.
CI_PROJECT_IDallallThe ID of the current project. This ID is unique across all projects on the GitLab instance.
CI_PROJECT_NAME8.100.5The name of the directory for the project. For example if the project URL is gitlab.example.com/group-name/project-1, CI_PROJECT_NAME is project-1.
CI_PROJECT_NAMESPACE8.100.5The project namespace (username or group name) of the job.
CI_PROJECT_NAMESPACE_ID15.70.5The project namespace ID of the job.
CI_PROJECT_PATH_SLUG9.3all $CI_PROJECT_PATH in lowercase with characters that are not a-z or 0-9 replaced with - and shortened to 63 bytes. Use in URLs and domain names.
CI_PROJECT_PATH8.100.5The project namespace with the project name included.
CI_PROJECT_REPOSITORY_LANGUAGES12.3allA comma-separated, lowercase list of the languages used in the repository. For example ruby,javascript,html,css. The maximum number of languages is limited to 5. An issue proposes to increase the limit.
CI_PROJECT_ROOT_NAMESPACE13.20.5The root project namespace (username or group name) of the job. For example, if CI_PROJECT_NAMESPACE is root-group/child-group/grandchild-group, CI_PROJECT_ROOT_NAMESPACE is root-group.
CI_PROJECT_TITLE12.4allThe human-readable project name as displayed in the GitLab web interface.
CI_PROJECT_DESCRIPTION15.1allThe project description as displayed in the GitLab web interface.
CI_PROJECT_URL8.100.5The HTTP(S) address of the project.
CI_PROJECT_VISIBILITY10.3allThe project visibility. Can be internal, private, or public.
CI_PROJECT_CLASSIFICATION_LABEL14.2allThe project external authorization classification label.
CI_REGISTRY_IMAGE8.100.5The address of the project’s Container Registry. Only available if the Container Registry is enabled for the project.
CI_REGISTRY_PASSWORD9.0allThe password to push containers to the project’s GitLab Container Registry. Only available if the Container Registry is enabled for the project. This password value is the same as the CI_JOB_TOKEN and is valid only as long as the job is running. Use the CI_DEPLOY_PASSWORD for long-lived access to the registry
CI_REGISTRY_USER9.0allThe username to push containers to the project’s GitLab Container Registry. Only available if the Container Registry is enabled for the project.
CI_REGISTRY8.100.5The address of the GitLab Container Registry. Only available if the Container Registry is enabled for the project. This variable includes a :port value if one is specified in the registry configuration.
CI_REPOSITORY_URL9.0allThe full path to Git clone (HTTP) the repository with a CI/CD job token, in the format https://gitlab-ci-token:$CI_JOB_TOKEN@gitlab.example.com/my-group/my-project.git.
CI_RUNNER_DESCRIPTION8.100.5The description of the runner.
CI_RUNNER_EXECUTABLE_ARCHall10.6The OS/architecture of the GitLab Runner executable. Might not be the same as the environment of the executor.
CI_RUNNER_ID8.100.5The unique ID of the runner being used.
CI_RUNNER_REVISIONall10.6The revision of the runner running the job.
CI_RUNNER_SHORT_TOKENall12.3The runner’s unique ID, used to authenticate new job requests. In GitLab 14.9 and later, the token contains a prefix, and the first 17 characters are used. Prior to 14.9, the first eight characters are used.
CI_RUNNER_TAGS8.100.5A comma-separated list of the runner tags.
CI_RUNNER_VERSIONall10.6The version of the GitLab Runner running the job.
CI_SERVER_HOST12.1allThe host of the GitLab instance URL, without protocol or port. For example gitlab.example.com.
CI_SERVER_NAMEallallThe name of CI/CD server that coordinates jobs.
CI_SERVER_PORT12.8allThe port of the GitLab instance URL, without host or protocol. For example 8080.
CI_SERVER_PROTOCOL12.8allThe protocol of the GitLab instance URL, without host or port. For example https.
CI_SERVER_SHELL_SSH_HOST15.11allThe SSH host of the GitLab instance, used for access to Git repositories via SSH. For example gitlab.com.
CI_SERVER_SHELL_SSH_PORT15.11allThe SSH port of the GitLab instance, used for access to Git repositories via SSH. For example 22.
CI_SERVER_REVISIONallallGitLab revision that schedules jobs.
CI_SERVER_TLS_CA_FILEallallFile containing the TLS CA certificate to verify the GitLab server when tls-ca-file set in runner settings.
CI_SERVER_TLS_CERT_FILEallallFile containing the TLS certificate to verify the GitLab server when tls-cert-file set in runner settings.
CI_SERVER_TLS_KEY_FILEallallFile containing the TLS key to verify the GitLab server when tls-key-file set in runner settings.
CI_SERVER_URL12.7allThe base URL of the GitLab instance, including protocol and port. For example https://gitlab.example.com:8080.
CI_SERVER_VERSION_MAJOR11.4allThe major version of the GitLab instance. For example, if the GitLab version is 13.6.1, the CI_SERVER_VERSION_MAJOR is 13.
CI_SERVER_VERSION_MINOR11.4allThe minor version of the GitLab instance. For example, if the GitLab version is 13.6.1, the CI_SERVER_VERSION_MINOR is 6.
CI_SERVER_VERSION_PATCH11.4allThe patch version of the GitLab instance. For example, if the GitLab version is 13.6.1, the CI_SERVER_VERSION_PATCH is 1.
CI_SERVER_VERSIONallallThe full version of the GitLab instance.
CI_SERVERallallAvailable for all jobs executed in CI/CD. yes when available.
CI_SHARED_ENVIRONMENTall10.1Only available if the job is executed in a shared environment (something that is persisted across CI/CD invocations, like the shell or ssh executor). true when available.
CI_TEMPLATE_REGISTRY_HOST15.3allThe host of the registry used by CI/CD templates. Defaults to registry.gitlab.com.
GITLAB_CIallallAvailable for all jobs executed in CI/CD. true when available.
GITLAB_FEATURES10.6allThe comma-separated list of licensed features available for the GitLab instance and license.
GITLAB_USER_EMAIL8.12allThe email of the user who started the pipeline, unless the job is a manual job. In manual jobs, the value is the email of the user who started the job.
GITLAB_USER_ID8.12allThe ID of the user who started the pipeline, unless the job is a manual job. In manual jobs, the value is the ID of the user who started the job.
GITLAB_USER_LOGIN10.0allThe username of the user who started the pipeline, unless the job is a manual job. In manual jobs, the value is the username of the user who started the job.
GITLAB_USER_NAME10.0allThe name of the user who started the pipeline, unless the job is a manual job. In manual jobs, the value is the name of the user who started the job.
KUBECONFIG14.2allThe path to the kubeconfig file with contexts for every shared agent connection. Only available when a GitLab agent is authorized to access the project.
TRIGGER_PAYLOAD13.9allThe webhook payload. Only available when a pipeline is triggered with a webhook.

Predefined variables for merge request pipelines

These variables are available when:

VariableGitLabRunnerDescription
CI_MERGE_REQUEST_APPROVED14.1allApproval status of the merge request. true when merge request approvals is available and the merge request has been approved.
CI_MERGE_REQUEST_ASSIGNEES11.9allComma-separated list of usernames of assignees for the merge request.
CI_MERGE_REQUEST_ID11.6allThe instance-level ID of the merge request. This is a unique ID across all projects on GitLab.
CI_MERGE_REQUEST_IID11.6allThe project-level IID (internal ID) of the merge request. This ID is unique for the current project.
CI_MERGE_REQUEST_LABELS11.9allComma-separated label names of the merge request.
CI_MERGE_REQUEST_MILESTONE11.9allThe milestone title of the merge request.
CI_MERGE_REQUEST_PROJECT_ID11.6allThe ID of the project of the merge request.
CI_MERGE_REQUEST_PROJECT_PATH11.6allThe path of the project of the merge request. For example namespace/awesome-project.
CI_MERGE_REQUEST_PROJECT_URL11.6allThe URL of the project of the merge request. For example, http://192.168.10.15:3000/namespace/awesome-project.
CI_MERGE_REQUEST_REF_PATH11.6allThe ref path of the merge request. For example, refs/merge-requests/1/head.
CI_MERGE_REQUEST_SQUASH_ON_MERGE16.4all true when the squash on merge option is set.
CI_MERGE_REQUEST_SOURCE_BRANCH_NAME11.6allThe source branch name of the merge request.
CI_MERGE_REQUEST_SOURCE_BRANCH_PROTECTED16.4all true when the source branch of the merge request is protected.
CI_MERGE_REQUEST_SOURCE_BRANCH_SHA11.9allThe HEAD SHA of the source branch of the merge request. The variable is empty in merge request pipelines. The SHA is present only in merged results pipelines.
CI_MERGE_REQUEST_SOURCE_PROJECT_ID11.6allThe ID of the source project of the merge request.
CI_MERGE_REQUEST_SOURCE_PROJECT_PATH11.6allThe path of the source project of the merge request.
CI_MERGE_REQUEST_SOURCE_PROJECT_URL11.6allThe URL of the source project of the merge request.
CI_MERGE_REQUEST_TARGET_BRANCH_NAME11.6allThe target branch name of the merge request.
CI_MERGE_REQUEST_TARGET_BRANCH_PROTECTED15.2all true when the target branch of the merge request is protected.
CI_MERGE_REQUEST_TARGET_BRANCH_SHA11.9allThe HEAD SHA of the target branch of the merge request. The variable is empty in merge request pipelines. The SHA is present only in merged results pipelines.
CI_MERGE_REQUEST_TITLE11.9allThe title of the merge request.
CI_MERGE_REQUEST_EVENT_TYPE12.3allThe event type of the merge request. Can be detached, merged_result or merge_train.
CI_MERGE_REQUEST_DIFF_ID13.7allThe version of the merge request diff.
CI_MERGE_REQUEST_DIFF_BASE_SHA13.7allThe base SHA of the merge request diff.

Predefined variables for external pull request pipelines

These variables are only available when:

VariableGitLabRunnerDescription
CI_EXTERNAL_PULL_REQUEST_IID12.3allPull request ID from GitHub.
CI_EXTERNAL_PULL_REQUEST_SOURCE_REPOSITORY13.3allThe source repository name of the pull request.
CI_EXTERNAL_PULL_REQUEST_TARGET_REPOSITORY13.3allThe target repository name of the pull request.
CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_NAME12.3allThe source branch name of the pull request.
CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_SHA12.3allThe HEAD SHA of the source branch of the pull request.
CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_NAME12.3allThe target branch name of the pull request.
CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_SHA12.3allThe HEAD SHA of the target branch of the pull request.

Deployment variables

Integrations that are responsible for deployment configuration can define their own predefined variables that are set in the build environment. These variables are only defined for deployment jobs.

For example, the Kubernetes integration defines deployment variables that you can use with the integration.

The documentation for each integration explains if the integration has any deployment variables available.