Predefined CI/CD variables reference

  • Tier: Free, Premium, Ultimate
  • Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated

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

Avoid overriding predefined variables, as it can cause the pipeline to behave unexpectedly.

Variable availability

Predefined variables become available at three different phases of pipeline execution:

  • Pre-pipeline: Pre-pipeline variables are available before the pipeline is created. These variables are the only variables that can be used with include:rules to control which configuration files to use when creating the pipeline.
  • Pipeline: Pipeline variables become available when GitLab is creating the pipeline. Along with pre-pipeline variables, pipeline variables can be used to configure rules defined in jobs, to determine which jobs to add to the pipeline.
  • Job-only: These variables are only made available to each job when a runner picks up the job and runs it, and:

Predefined variables

VariableAvailabilityDescription
CHAT_CHANNELPipelineThe Source chat channel that triggered the ChatOps command.
CHAT_INPUTPipelineThe additional arguments passed with the ChatOps command.
CHAT_USER_IDPipelineThe chat service’s user ID of the user who triggered the ChatOps command.
CIPre-pipelineAvailable for all jobs executed in CI/CD. true when available.
CI_API_V4_URLPre-pipelineThe GitLab API v4 root URL.
CI_API_GRAPHQL_URLPre-pipelineThe GitLab API GraphQL root URL. Introduced in GitLab 15.11.
CI_BUILDS_DIRJob-onlyThe top-level directory where builds are executed.
CI_COMMIT_AUTHORPre-pipelineThe author of the commit in Name <email> format.
CI_COMMIT_BEFORE_SHAPre-pipelineThe previous latest commit present on a branch or tag. Is always 0000000000000000000000000000000000000000 for merge request pipelines, the first commit in pipelines for branches or tags, or when manually running a pipeline.
CI_COMMIT_BRANCHPre-pipelineThe commit branch name. Available in branch pipelines, including pipelines for the default branch. Not available in merge request pipelines or tag pipelines.
CI_COMMIT_DESCRIPTIONPre-pipelineThe description of the commit. If the title is shorter than 100 characters, the message without the first line.
CI_COMMIT_MESSAGEPre-pipelineThe full commit message.
CI_COMMIT_REF_NAMEPre-pipelineThe branch or tag name for which project is built.
CI_COMMIT_REF_PROTECTEDPre-pipelinetrue if the job is running for a protected reference, false otherwise.
CI_COMMIT_REF_SLUGPre-pipelineCI_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_SHAPre-pipelineThe commit revision the project is built for.
CI_COMMIT_SHORT_SHAPre-pipelineThe first eight characters of CI_COMMIT_SHA.
CI_COMMIT_TAGPre-pipelineThe commit tag name. Available only in pipelines for tags.
CI_COMMIT_TAG_MESSAGEPre-pipelineThe commit tag message. Available only in pipelines for tags. Introduced in GitLab 15.5.
CI_COMMIT_TIMESTAMPPre-pipelineThe timestamp of the commit in the ISO 8601 format. For example, 2022-01-31T16:47:55Z. UTC by default.
CI_COMMIT_TITLEPre-pipelineThe title of the commit. The full first line of the message.
CI_CONCURRENT_IDJob-onlyThe unique ID of build execution in a single executor.
CI_CONCURRENT_PROJECT_IDJob-onlyThe unique ID of build execution in a single executor and project.
CI_CONFIG_PATHPre-pipelineThe path to the CI/CD configuration file. Defaults to .gitlab-ci.yml.
CI_DEBUG_TRACEPipelinetrue if debug logging (tracing) is enabled.
CI_DEBUG_SERVICESPipelinetrue if service container logging is enabled. Introduced in GitLab 15.7. Requires GitLab Runner 15.7.
CI_DEFAULT_BRANCHPre-pipelineThe name of the project’s default branch.
CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIXPre-pipelineThe direct group image prefix for pulling images through the Dependency Proxy.
CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIXPre-pipelineThe top-level group image prefix for pulling images through the Dependency Proxy.
CI_DEPENDENCY_PROXY_PASSWORDPipelineThe password to pull images through the Dependency Proxy.
CI_DEPENDENCY_PROXY_SERVERPre-pipelineThe server for logging in to the Dependency Proxy. This variable is equivalent to $CI_SERVER_HOST:$CI_SERVER_PORT.
CI_DEPENDENCY_PROXY_USERPipelineThe username to pull images through the Dependency Proxy.
CI_DEPLOY_FREEZEPre-pipelineOnly available if the pipeline runs during a deploy freeze window. true when available.
CI_DEPLOY_PASSWORDJob-onlyThe authentication password of the GitLab Deploy Token, if the project has one.
CI_DEPLOY_USERJob-onlyThe authentication username of the GitLab Deploy Token, if the project has one.
CI_DISPOSABLE_ENVIRONMENTPipelineOnly 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_NAMEPipelineThe name of the environment for this job. Available if environment:name is set.
CI_ENVIRONMENT_SLUGPipelineThe 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_URLPipelineThe URL of the environment for this job. Available if environment:url is set.
CI_ENVIRONMENT_ACTIONPipelineThe action annotation specified for this job’s environment. Available if environment:action is set. Can be start, prepare, or stop.
CI_ENVIRONMENT_TIERPipelineThe deployment tier of the environment for this job.
CI_GITLAB_FIPS_MODEPre-pipelineOnly available if FIPS mode is enabled in the GitLab instance. true when available.
CI_HAS_OPEN_REQUIREMENTSPipelineOnly available if the pipeline’s project has an open requirement. true when available.
CI_JOB_IDJob-onlyThe internal ID of the job, unique across all jobs in the GitLab instance.
CI_JOB_IMAGEPipelineThe name of the Docker image running the job.
CI_JOB_MANUALPipelineOnly available if the job was started manually. true when available.
CI_JOB_NAMEPipelineThe name of the job.
CI_JOB_NAME_SLUGPipelineCI_JOB_NAME in lowercase, shortened to 63 bytes, and with everything except 0-9 and a-z replaced with -. No leading / trailing -. Use in paths. Introduced in GitLab 15.4.
CI_JOB_STAGEPipelineThe name of the job’s stage.
CI_JOB_STATUSJob-onlyThe status of the job as each runner stage is executed. Use with after_script. Can be success, failed, or canceled.
CI_JOB_TIMEOUTJob-onlyThe job timeout, in seconds. Introduced in GitLab 15.7. Requires GitLab Runner 15.7.
CI_JOB_TOKENJob-onlyA token to authenticate with certain API endpoints. The token is valid as long as the job is running.
CI_JOB_URLJob-onlyThe job details URL.
CI_JOB_STARTED_ATJob-onlyThe date and time when a job started, in ISO 8601 format. For example, 2022-01-31T16:47:55Z. UTC by default.
CI_KUBERNETES_ACTIVEPre-pipelineOnly available if the pipeline has a Kubernetes cluster available for deployments. true when available.
CI_NODE_INDEXPipelineThe index of the job in the job set. Only available if the job uses parallel.
CI_NODE_TOTALPipelineThe total number of instances of this job running in parallel. Set to 1 if the job does not use parallel.
CI_OPEN_MERGE_REQUESTSPre-pipelineA 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_DOMAINPre-pipelineThe instance’s domain that hosts GitLab Pages, not including the namespace subdomain. To use the full hostname, use CI_PAGES_HOSTNAME instead.
CI_PAGES_HOSTNAMEJob-onlyThe full hostname of the Pages deployment.
CI_PAGES_URLJob-onlyThe URL for a GitLab Pages site. Always a subdomain of CI_PAGES_DOMAIN. In GitLab 17.9 and later, the value includes the path_prefix when one is specified.
CI_PIPELINE_IDJob-onlyThe instance-level ID of the current pipeline. This ID is unique across all projects on the GitLab instance.
CI_PIPELINE_IIDPipelineThe project-level IID (internal ID) of the current pipeline. This ID is unique only in the current project.
CI_PIPELINE_SOURCEPre-pipelineHow the pipeline was triggered. The value can be one of the pipeline sources.
CI_PIPELINE_TRIGGEREDPipelinetrue if the job was triggered.
CI_PIPELINE_URLJob-onlyThe URL for the pipeline details.
CI_PIPELINE_CREATED_ATPre-pipelineThe date and time when the pipeline was created, in ISO 8601 format. For example, 2022-01-31T16:47:55Z. UTC by default.
CI_PIPELINE_NAMEPre-pipelineThe pipeline name defined in workflow:name. Introduced in GitLab 16.3.
CI_PIPELINE_SCHEDULE_DESCRIPTIONPre-pipelineThe description of the pipeline schedule. Only available in scheduled pipelines. Introduced in GitLab 17.8.
CI_PROJECT_DIRJob-onlyThe 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_IDPre-pipelineThe ID of the current project. This ID is unique across all projects on the GitLab instance.
CI_PROJECT_NAMEPre-pipelineThe 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_NAMESPACEPre-pipelineThe project namespace (username or group name) of the job.
CI_PROJECT_NAMESPACE_IDPre-pipelineThe project namespace ID of the job. Introduced in GitLab 15.7.
CI_PROJECT_PATH_SLUGPre-pipeline$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_PATHPre-pipelineThe project namespace with the project name included.
CI_PROJECT_REPOSITORY_LANGUAGESPre-pipelineA 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_NAMESPACEPre-pipelineThe 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_TITLEPre-pipelineThe human-readable project name as displayed in the GitLab web interface.
CI_PROJECT_DESCRIPTIONPre-pipelineThe project description as displayed in the GitLab web interface. Introduced in GitLab 15.1.
CI_PROJECT_URLPre-pipelineThe HTTP(S) address of the project.
CI_PROJECT_VISIBILITYPre-pipelineThe project visibility. Can be internal, private, or public.
CI_PROJECT_CLASSIFICATION_LABELPre-pipelineThe project external authorization classification label.
CI_REGISTRYPre-pipelineAddress of the container registry server, formatted as <host>[:<port>]. For example: registry.gitlab.example.com. Only available if the container registry is enabled for the GitLab instance.
CI_REGISTRY_IMAGEPre-pipelineBase address for the container registry to push, pull, or tag project’s images, formatted as <host>[:<port>]/<project_full_path>. For example: registry.gitlab.example.com/my_group/my_project. Image names must follow the container registry naming convention. Only available if the container registry is enabled for the project.
CI_REGISTRY_PASSWORDJob-onlyThe password to push containers to the GitLab project’s 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_USERJob-onlyThe username to push containers to the project’s GitLab container registry. Only available if the container registry is enabled for the project.
CI_RELEASE_DESCRIPTIONPipelineThe description of the release. Available only on pipelines for tags. Description length is limited to first 1024 characters. Introduced in GitLab 15.5.
CI_REPOSITORY_URLJob-onlyThe 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_DESCRIPTIONJob-onlyThe description of the runner.
CI_RUNNER_EXECUTABLE_ARCHJob-onlyThe OS/architecture of the GitLab Runner executable. Might not be the same as the environment of the executor.
CI_RUNNER_IDJob-onlyThe unique ID of the runner being used.
CI_RUNNER_REVISIONJob-onlyThe revision of the runner running the job.
CI_RUNNER_SHORT_TOKENJob-onlyThe runner’s unique ID, used to authenticate new job requests. The token contains a prefix, and the first 17 characters are used.
CI_RUNNER_TAGSJob-onlyA JSON array of runner tags. For example ["tag_1", "tag_2"].
CI_RUNNER_VERSIONJob-onlyThe version of the GitLab Runner running the job.
CI_SERVER_FQDNPre-pipelineThe fully qualified domain name (FQDN) of the instance. For example gitlab.example.com:8080. Introduced in GitLab 16.10.
CI_SERVER_HOSTPre-pipelineThe host of the GitLab instance URL, without protocol or port. For example gitlab.example.com.
CI_SERVER_NAMEPre-pipelineThe name of CI/CD server that coordinates jobs.
CI_SERVER_PORTPre-pipelineThe port of the GitLab instance URL, without host or protocol. For example 8080.
CI_SERVER_PROTOCOLPre-pipelineThe protocol of the GitLab instance URL, without host or port. For example https.
CI_SERVER_SHELL_SSH_HOSTPre-pipelineThe SSH host of the GitLab instance, used for access to Git repositories through SSH. For example gitlab.com. Introduced in GitLab 15.11.
CI_SERVER_SHELL_SSH_PORTPre-pipelineThe SSH port of the GitLab instance, used for access to Git repositories through SSH. For example 22. Introduced in GitLab 15.11.
CI_SERVER_REVISIONPre-pipelineGitLab revision that schedules jobs.
CI_SERVER_TLS_CA_FILEPipelineFile containing the TLS CA certificate to verify the GitLab server when tls-ca-file set in runner settings.
CI_SERVER_TLS_CERT_FILEPipelineFile containing the TLS certificate to verify the GitLab server when tls-cert-file set in runner settings.
CI_SERVER_TLS_KEY_FILEPipelineFile containing the TLS key to verify the GitLab server when tls-key-file set in runner settings.
CI_SERVER_URLPre-pipelineThe base URL of the GitLab instance, including protocol and port. For example https://gitlab.example.com:8080.
CI_SERVER_VERSION_MAJORPre-pipelineThe major version of the GitLab instance. For example, if the GitLab version is 17.2.1, the CI_SERVER_VERSION_MAJOR is 17.
CI_SERVER_VERSION_MINORPre-pipelineThe minor version of the GitLab instance. For example, if the GitLab version is 17.2.1, the CI_SERVER_VERSION_MINOR is 2.
CI_SERVER_VERSION_PATCHPre-pipelineThe patch version of the GitLab instance. For example, if the GitLab version is 17.2.1, the CI_SERVER_VERSION_PATCH is 1.
CI_SERVER_VERSIONPre-pipelineThe full version of the GitLab instance.
CI_SERVERJob-onlyAvailable for all jobs executed in CI/CD. yes when available.
CI_SHARED_ENVIRONMENTPipelineOnly 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_HOSTPre-pipelineThe host of the registry used by CI/CD templates. Defaults to registry.gitlab.com. Introduced in GitLab 15.3.
CI_TRIGGER_SHORT_TOKENJob-onlyFirst 4 characters of the trigger token of the current job. Only available if the pipeline was triggered with a trigger token. For example, for a trigger token of glptt-1234567890abcdefghij, CI_TRIGGER_SHORT_TOKEN would be 1234. Introduced in GitLab 17.0.
GITLAB_CIPre-pipelineAvailable for all jobs executed in CI/CD. true when available.
GITLAB_FEATURESPre-pipelineThe comma-separated list of licensed features available for the GitLab instance and license.
GITLAB_USER_EMAILPipelineThe 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_IDPipelineThe numeric 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_LOGINPipelineThe unique 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_NAMEPipelineThe display name (user-defined Full name in the profile settings) 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.
KUBECONFIGPipelineThe 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_PAYLOADPipelineThe webhook payload. Only available when a pipeline is triggered with a webhook.

Predefined variables for merge request pipelines

These variables are available before GitLab creates the pipeline (Pre-pipeline). These variables can be used with include:rules to control which configuration files to use when creating the pipeline.

The pipeline must be a merge request pipeline, and the merge request must be open.

VariableDescription
CI_MERGE_REQUEST_APPROVEDApproval status of the merge request. true when merge request approvals is available and the merge request has been approved.
CI_MERGE_REQUEST_ASSIGNEESComma-separated list of usernames of assignees for the merge request.
CI_MERGE_REQUEST_DIFF_BASE_SHAThe base SHA of the merge request diff.
CI_MERGE_REQUEST_DIFF_IDThe version of the merge request diff.
CI_MERGE_REQUEST_EVENT_TYPEThe event type of the merge request. Can be detached, merged_result or merge_train.
CI_MERGE_REQUEST_DESCRIPTIONThe description of the merge request. If the description is more than 2700 characters long, only the first 2700 characters are stored in the variable. Introduced in GitLab 16.7.
CI_MERGE_REQUEST_DESCRIPTION_IS_TRUNCATEDtrue if CI_MERGE_REQUEST_DESCRIPTION is truncated down to 2700 characters because the description of the merge request is too long. Introduced in GitLab 16.8.
CI_MERGE_REQUEST_IDThe instance-level ID of the merge request. The ID is unique across all projects on the GitLab instance.
CI_MERGE_REQUEST_IIDThe project-level IID (internal ID) of the merge request. This ID is unique for the current project, and is the number used in the merge request URL, page title, and other visible locations.
CI_MERGE_REQUEST_LABELSComma-separated label names of the merge request.
CI_MERGE_REQUEST_MILESTONEThe milestone title of the merge request.
CI_MERGE_REQUEST_PROJECT_IDThe ID of the project of the merge request.
CI_MERGE_REQUEST_PROJECT_PATHThe path of the project of the merge request. For example namespace/awesome-project.
CI_MERGE_REQUEST_PROJECT_URLThe URL of the project of the merge request. For example, http://192.168.10.15:3000/namespace/awesome-project.
CI_MERGE_REQUEST_REF_PATHThe ref path of the merge request. For example, refs/merge-requests/1/head.
CI_MERGE_REQUEST_SOURCE_BRANCH_NAMEThe source branch name of the merge request.
CI_MERGE_REQUEST_SOURCE_BRANCH_PROTECTEDtrue when the source branch of the merge request is protected. Introduced in GitLab 16.4.
CI_MERGE_REQUEST_SOURCE_BRANCH_SHAThe 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_IDThe ID of the source project of the merge request.
CI_MERGE_REQUEST_SOURCE_PROJECT_PATHThe path of the source project of the merge request.
CI_MERGE_REQUEST_SOURCE_PROJECT_URLThe URL of the source project of the merge request.
CI_MERGE_REQUEST_SQUASH_ON_MERGEtrue when the squash on merge option is set. Introduced in GitLab 16.4.
CI_MERGE_REQUEST_TARGET_BRANCH_NAMEThe target branch name of the merge request.
CI_MERGE_REQUEST_TARGET_BRANCH_PROTECTEDtrue when the target branch of the merge request is protected. Introduced in GitLab 15.2.
CI_MERGE_REQUEST_TARGET_BRANCH_SHAThe 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_TITLEThe title of the merge request.

Predefined variables for external pull request pipelines

These variables are only available when:

VariableDescription
CI_EXTERNAL_PULL_REQUEST_IIDPull request ID from GitHub.
CI_EXTERNAL_PULL_REQUEST_SOURCE_REPOSITORYThe source repository name of the pull request.
CI_EXTERNAL_PULL_REQUEST_TARGET_REPOSITORYThe target repository name of the pull request.
CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_NAMEThe source branch name of the pull request.
CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_SHAThe HEAD SHA of the source branch of the pull request.
CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_NAMEThe target branch name of the pull request.
CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_SHAThe 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.

Auto DevOps variables

When Auto DevOps is enabled, some additional pre-pipeline variables are made available:

Integration variables

Some integrations make variables available in jobs. These variables are available as job-only predefined variables:

  • Harbor:
    • HARBOR_URL
    • HARBOR_HOST
    • HARBOR_OCI
    • HARBOR_PROJECT
    • HARBOR_USERNAME
    • HARBOR_PASSWORD
  • Apple App Store Connect:
    • APP_STORE_CONNECT_API_KEY_ISSUER_ID
    • APP_STORE_CONNECT_API_KEY_KEY_ID
    • APP_STORE_CONNECT_API_KEY_KEY
    • APP_STORE_CONNECT_API_KEY_IS_KEY_CONTENT_BASE64
  • Google Play:
    • SUPPLY_PACKAGE_NAME
    • SUPPLY_JSON_KEY_DATA
  • Diffblue Cover:
    • DIFFBLUE_LICENSE_KEY
    • DIFFBLUE_ACCESS_TOKEN_NAME
    • DIFFBLUE_ACCESS_TOKEN

Troubleshooting

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