Predefined environment variables reference

For an introduction on this subject, read through the getting started with environment variables document.

Overview

Some of the predefined environment variables are available only if a minimum version of GitLab Runner is used. Consult the table below to find the version of Runner required.

Note: Starting with GitLab 9.0, we have deprecated some variables. Read the 9.0 Renaming section to find out their replacements. You are strongly advised to use the new variables as we will remove the old ones in future GitLab releases.

Variables reference

VariableGitLabRunnerDescription
ARTIFACT_DOWNLOAD_ATTEMPTS8.151.9Number of attempts to download artifacts running a job
CHAT_CHANNEL10.6allSource chat channel which triggered the ChatOps command
CHAT_INPUT10.6allAdditional arguments passed in the ChatOps command
CIall0.4Mark that job is executed in CI environment
CI_API_V4_URL11.7allThe GitLab API v4 root URL
CI_BUILDS_DIRall11.10Top-level directory where builds are executed.
CI_COMMIT_BEFORE_SHA11.2allThe previous latest commit present on a branch before a merge request. Only populated when there is a merge request associated with the pipeline.
CI_COMMIT_DESCRIPTION10.8allThe description of the commit: the message without first line, if the title is shorter than 100 characters; full message in other case.
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.11allIf the job is running on a protected branch
CI_COMMIT_REF_SLUG9.0all$CI_COMMIT_REF_NAME lowercased, 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 for which project is built
CI_COMMIT_SHORT_SHA11.7allThe first eight characters of CI_COMMIT_SHA
CI_COMMIT_TAG9.00.5The commit tag name. Present only when building tags.
CI_COMMIT_TITLE10.8allThe title of the commit - the full first line of the message
CI_CONCURRENT_IDall11.10Unique ID of build execution within a single executor.
CI_CONCURRENT_PROJECT_IDall11.10Unique ID of build execution within a single executor and project.
CI_CONFIG_PATH9.40.5The path to CI config file. Defaults to .gitlab-ci.yml
CI_DEBUG_TRACEall1.7Whether debug logging (tracing) is enabled
CI_DEFAULT_BRANCH12.4allThe name of the default branch for the project.
CI_DEPLOY_PASSWORD10.8allAuthentication password of the GitLab Deploy Token, only present if the Project has one related.
CI_DEPLOY_USER10.8allAuthentication username of the GitLab Deploy Token, only present if the Project has one related.
CI_DISPOSABLE_ENVIRONMENTall10.1Marks that 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). If the environment is disposable, it is set to true, otherwise it is not defined at all.
CI_ENVIRONMENT_NAME8.15allThe name of the environment for this job. Only present if environment:name is set.
CI_ENVIRONMENT_SLUG8.15allA simplified version of the environment name, suitable for inclusion in DNS, URLs, Kubernetes labels, etc. Only present if environment:name is set.
CI_ENVIRONMENT_URL9.3allThe URL of the environment for this job. Only present if environment:url is set.
CI_EXTERNAL_PULL_REQUEST_IID12.3allPull Request ID from GitHub if the pipelines are for external pull requests. Available only if only: [external_pull_requests] is used and the pull request is open.
CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_NAME12.3allThe source branch name of the pull request if the pipelines are for external pull requests. Available only if only: [external_pull_requests] is used and the pull request is open.
CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_SHA12.3allThe HEAD SHA of the source branch of the pull request if the pipelines are for external pull requests. Available only if only: [external_pull_requests] is used and the pull request is open.
CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_NAME12.3allThe target branch name of the pull request if the pipelines are for external pull requests. Available only if only: [external_pull_requests] is used and the pull request is open.
CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_SHA12.3allThe HEAD SHA of the target branch of the pull request if the pipelines are for external pull requests. Available only if only: [external_pull_requests] is used and the pull request is open.
CI_JOB_ID9.0allThe unique id of the current job that GitLab CI uses internally
CI_JOB_MANUAL8.12allThe flag to indicate that job was manually started
CI_JOB_NAME9.00.5The name of the job as defined in .gitlab-ci.yml
CI_JOB_STAGE9.00.5The name of the stage as defined in .gitlab-ci.yml
CI_JOB_TOKEN9.01.2Token used for authenticating with the GitLab Container Registry and downloading dependent repositories
CI_JOB_URL11.10.5Job details URL
CI_MERGE_REQUEST_ASSIGNEES11.9allComma-separated list of username(s) of assignee(s) for the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] is used and the merge request is created.
CI_MERGE_REQUEST_ID11.6allThe ID of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] is used and the merge request is created.
CI_MERGE_REQUEST_IID11.6allThe IID of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] is used and the merge request is created.
CI_MERGE_REQUEST_LABELS11.9allComma-separated label names of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] is used and the merge request is created.
CI_MERGE_REQUEST_MILESTONE11.9allThe milestone title of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] is used and the merge request is created.
CI_MERGE_REQUEST_PROJECT_ID11.6allThe ID of the project of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] is used and the merge request is created.
CI_MERGE_REQUEST_PROJECT_PATH11.6allThe path of the project of the merge request if the pipelines are for merge requests (e.g. namespace/awesome-project). Available only if only: [merge_requests] is used and the merge request is created.
CI_MERGE_REQUEST_PROJECT_URL11.6allThe URL of the project of the merge request if the pipelines are for merge requests (e.g. http://192.168.10.15:3000/namespace/awesome-project). Available only if only: [merge_requests] is used and the merge request is created.
CI_MERGE_REQUEST_REF_PATH11.6allThe ref path of the merge request if the pipelines are for merge requests. (e.g. refs/merge-requests/1/head). Available only if only: [merge_requests] is used and the merge request is created.
CI_MERGE_REQUEST_SOURCE_BRANCH_NAME11.6allThe source branch name of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] is used and the merge request is created.
CI_MERGE_REQUEST_SOURCE_BRANCH_SHA11.9allThe HEAD SHA of the source branch of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] is used, the merge request is created, and the pipeline is a merged result pipeline.
CI_MERGE_REQUEST_SOURCE_PROJECT_ID11.6allThe ID of the source project of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] is used and the merge request is created.
CI_MERGE_REQUEST_SOURCE_PROJECT_PATH11.6allThe path of the source project of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] is used and the merge request is created.
CI_MERGE_REQUEST_SOURCE_PROJECT_URL11.6allThe URL of the source project of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] is used and the merge request is created.
CI_MERGE_REQUEST_TARGET_BRANCH_NAME11.6allThe target branch name of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] is used and the merge request is created.
CI_MERGE_REQUEST_TARGET_BRANCH_SHA11.9allThe HEAD SHA of the target branch of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] is used, the merge request is created, and the pipeline is a merged result pipeline.
CI_MERGE_REQUEST_TITLE11.9allThe title of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] is used and the merge request is created.
CI_NODE_INDEX11.5allIndex of the job in the job set. If the job is not parallelized, this variable is not set.
CI_NODE_TOTAL11.5allTotal number of instances of this job running in parallel. If the job is not parallelized, this variable is set to 1.
CI_PAGES_DOMAIN11.8allThe configured domain that hosts GitLab Pages.
CI_PAGES_URL11.8allURL to GitLab Pages-built pages. Always belongs to a subdomain of CI_PAGES_DOMAIN.
CI_PIPELINE_ID8.10allThe unique id of the current pipeline that GitLab CI uses internally
CI_PIPELINE_IID11.0allThe unique id of the current pipeline scoped to project
CI_PIPELINE_SOURCE10.0allIndicates how the pipeline was triggered. Possible options are: push, web, trigger, schedule, api, pipeline and merge_request_event. For pipelines created before GitLab 9.5, this will show as unknown
CI_PIPELINE_TRIGGEREDallallThe flag to indicate that job was triggered
CI_PIPELINE_URL11.10.5Pipeline details URL
CI_PROJECT_DIRallallThe full path where the repository is cloned and where the job is run. If the GitLab Runner builds_dir parameter is set, this variable is set relative to the value of builds_dir. For more information, see Advanced configuration for GitLab Runner.
CI_PROJECT_IDallallThe unique id of the current project that GitLab CI uses internally
CI_PROJECT_NAME8.100.5The name of the directory for the project that is currently being built. For example, if the project URL is gitlab.example.com/group-name/project-1, the CI_PROJECT_NAME would be project-1.
CI_PROJECT_NAMESPACE8.100.5The project namespace (username or groupname) that is currently being built
CI_PROJECT_PATH8.100.5The namespace with project name
CI_PROJECT_PATH_SLUG9.3all$CI_PROJECT_PATH lowercased and with everything except 0-9 and a-z replaced with -. Use in URLs and domain names.
CI_PROJECT_REPOSITORY_LANGUAGES12.3allComma-separated, lowercased list of the languages used in the repository (e.g. ruby,javascript,html,css)
CI_PROJECT_TITLE12.4allThe human-readable project name as displayed in the GitLab web interface.
CI_PROJECT_URL8.100.5The HTTP(S) address to access project
CI_PROJECT_VISIBILITY10.3allThe project visibility (internal, private, public)
CI_REGISTRY8.100.5If the Container Registry is enabled it returns the address of GitLab’s Container Registry. This variable will include a :port value if one has been specified in the registry configuration.
CI_REGISTRY_IMAGE8.100.5If the Container Registry is enabled for the project it returns the address of the registry tied to the specific project
CI_REGISTRY_PASSWORD9.0allThe password to use to push containers to the GitLab Container Registry
CI_REGISTRY_USER9.0allThe username to use to push containers to the GitLab Container Registry
CI_REPOSITORY_URL9.0allThe URL to clone the Git repository
CI_RUNNER_DESCRIPTION8.100.5The description of the runner as saved in GitLab
CI_RUNNER_EXECUTABLE_ARCHall10.6The OS/architecture of the GitLab Runner executable (note that this is not necessarily the same as the environment of the executor)
CI_RUNNER_ID8.100.5The unique id of runner being used
CI_RUNNER_REVISIONall10.6GitLab Runner revision that is executing the current job
CI_RUNNER_SHORT_TOKENall12.3First eight characters of GitLab Runner’s token used to authenticate new job requests. Used as Runner’s unique ID
CI_RUNNER_TAGS8.100.5The defined runner tags
CI_RUNNER_VERSIONall10.6GitLab Runner version that is executing the current job
CI_SERVERallallMark that job is executed in CI environment
CI_SERVER_HOST12.1allHost component of the GitLab instance URL, without protocol and port (like gitlab.example.com)
CI_SERVER_NAMEallallThe name of CI server that is used to coordinate jobs
CI_SERVER_REVISIONallallGitLab revision that is used to schedule jobs
CI_SERVER_VERSIONallallGitLab version that is used to schedule jobs
CI_SERVER_VERSION_MAJOR11.4allGitLab version major component
CI_SERVER_VERSION_MINOR11.4allGitLab version minor component
CI_SERVER_VERSION_PATCH11.4allGitLab version patch component
CI_SHARED_ENVIRONMENTall10.1Marks that the job is executed in a shared environment (something that is persisted across CI invocations like shell or ssh executor). If the environment is shared, it is set to true, otherwise it is not defined at all.
GET_SOURCES_ATTEMPTS8.151.9Number of attempts to fetch sources running a job
GITLAB_CIallallMark that job is executed in GitLab CI environment
GITLAB_FEATURES10.6allThe comma separated list of licensed features available for your instance and plan
GITLAB_USER_EMAIL8.12allThe email of the user who started the job
GITLAB_USER_ID8.12allThe id of the user who started the job
GITLAB_USER_LOGIN10.0allThe login username of the user who started the job
GITLAB_USER_NAME10.0allThe real name of the user who started the job
RESTORE_CACHE_ATTEMPTS8.151.9Number of attempts to restore the cache running a job