学习笔记 · 2017年12月14日

gitlab-ci 默认变量

浏览:113

摘自官方文档,由于官方网站太难访问,留存以备用:

Predefined environment variables reference

VariableDescription
CHAT_CHANNELSource chat channel which triggered the ChatOps command.
CHAT_INPUTAdditional arguments passed in the ChatOps command.
CIMark that job is executed in CI environment.
CI_API_V4_URLThe GitLab API v4 root URL.
CI_BUILDS_DIRTop-level directory where builds are executed.
CI_COMMIT_BEFORE_SHAThe previous latest commit present on a branch. Is always 0000000000000000000000000000000000000000 in pipelines for merge requests.
CI_COMMIT_DESCRIPTIONThe description of the commit: the message without first line, if the title is shorter than 100 characters; full message in other case.
CI_COMMIT_MESSAGEThe full commit message.
CI_COMMIT_REF_NAMEThe branch or tag name for which project is built.
CI_COMMIT_REF_PROTECTEDtrue if the job is running on a protected reference, false if not.
CI_COMMIT_REF_SLUG$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_SHAThe commit revision for which project is built.
CI_COMMIT_SHORT_SHAThe first eight characters of CI_COMMIT_SHA.
CI_COMMIT_BRANCHThe commit branch name. Present in branch pipelines, including pipelines for the default branch. Not present in merge request pipelines or tag pipelines.
CI_COMMIT_TAGThe commit tag name. Present only when building tags.
CI_COMMIT_TITLEThe title of the commit - the full first line of the message.
CI_COMMIT_TIMESTAMPThe timestamp of the commit in the ISO 8601 format.
CI_CONCURRENT_IDUnique ID of build execution in a single executor.
CI_CONCURRENT_PROJECT_IDUnique ID of build execution in a single executor and project.
CI_CONFIG_PATHThe path to CI configuration file. Defaults to .gitlab-ci.yml.
CI_DEBUG_TRACEWhether debug logging (tracing) is enabled.
CI_DEFAULT_BRANCHThe name of the default branch for the project.
CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIXThe image prefix for pulling images through the Dependency Proxy.
CI_DEPENDENCY_PROXY_SERVERThe server for logging in to the Dependency Proxy. This is equivalent to $CI_SERVER_HOST:$CI_SERVER_PORT.
CI_DEPENDENCY_PROXY_PASSWORDThe password to use to pull images through the Dependency Proxy.
CI_DEPENDENCY_PROXY_USERThe username to use to pull images through the Dependency Proxy.
CI_DEPLOY_FREEZEIncluded with the value true if the pipeline runs during a deploy freeze window.
CI_DEPLOY_PASSWORDAuthentication password of the GitLab Deploy Token, only present if the Project has one related.
CI_DEPLOY_USERAuthentication username of the GitLab Deploy Token, only present if the Project has one related.
CI_DISPOSABLE_ENVIRONMENTMarks 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_NAMEThe name of the environment for this job. Only present if environment:name is set.
CI_ENVIRONMENT_SLUGA simplified version of the environment name, suitable for inclusion in DNS, URLs, Kubernetes labels, and so on. Only present if environment:name is set.
CI_ENVIRONMENT_URLThe URL of the environment for this job. Only present if environment:url is set.
CI_EXTERNAL_PULL_REQUEST_IIDPull Request ID from GitHub if the pipelines are for external pull requests. Available only if only: [external_pull_requests] or rules syntax is used and the pull request is open.
CI_EXTERNAL_PULL_REQUEST_SOURCE_REPOSITORYThe source repository name of the pull request if the pipelines are for external pull requests. Available only if only: [external_pull_requests] or rules syntax is used and the pull request is open.
CI_EXTERNAL_PULL_REQUEST_TARGET_REPOSITORYThe target repository name of the pull request if the pipelines are for external pull requests. Available only if only: [external_pull_requests] or rules syntax is used and the pull request is open.
CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_NAMEThe source branch name of the pull request if the pipelines are for external pull requests. Available only if only: [external_pull_requests] or rules syntax is used and the pull request is open.
CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_SHAThe 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] or rules syntax is used and the pull request is open.
CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_NAMEThe target branch name of the pull request if the pipelines are for external pull requests. Available only if only: [external_pull_requests] or rules syntax is used and the pull request is open.
CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_SHAThe 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] or rules syntax is used and the pull request is open.
CI_HAS_OPEN_REQUIREMENTSIncluded with the value true only if the pipeline’s project has any open requirements. Not included if there are no open requirements for the pipeline’s project.
CI_OPEN_MERGE_REQUESTSAvailable in branch and merge request pipelines. Contains a comma-separated list of up to four merge requests that use the current branch and project as the merge request source. For example gitlab-org/gitlab!333,gitlab-org/gitlab-foss!11.
CI_JOB_IDThe unique ID of the current job that GitLab CI/CD uses internally.
CI_JOB_IMAGEThe name of the image running the CI job.
CI_JOB_MANUALThe flag to indicate that job was manually started.
CI_JOB_NAMEThe name of the job as defined in .gitlab-ci.yml.
CI_JOB_STAGEThe name of the stage as defined in .gitlab-ci.yml.
CI_JOB_STATUSThe state of the job as each runner stage is executed. Use with after_script where CI_JOB_STATUS can be either: success, failed or canceled.
CI_JOB_TOKENToken used for authenticating with a few API endpoints and downloading dependent repositories. The token is valid as long as the job is running.
CI_JOB_JWTRS256 JSON web token that can be used for authenticating with third party systems that support JWT authentication, for example HashiCorp’s Vault.
CI_JOB_URLJob details URL.
CI_KUBERNETES_ACTIVEIncluded with the value true only if the pipeline has a Kubernetes cluster available for deployments. Not included if no cluster is available. Can be used as an alternative to only:kubernetes/except:kubernetes with rules:if.
CI_MERGE_REQUEST_ASSIGNEESComma-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] or rules syntax is used and the merge request is created.
CI_MERGE_REQUEST_IDThe instance-level ID of the merge request. Only available if the pipelines are for merge requests and the merge request is created. This is a unique ID across all projects on GitLab.
CI_MERGE_REQUEST_IIDThe project-level IID (internal ID) of the merge request. Only available If the pipelines are for merge requests and the merge request is created. This ID is unique for the current project.
CI_MERGE_REQUEST_LABELSComma-separated label names of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] or rules syntax is used and the merge request is created.
CI_MERGE_REQUEST_MILESTONEThe milestone title of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] or rules syntax is used and the merge request is created.
CI_MERGE_REQUEST_PROJECT_IDThe ID of the project of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] or rules syntax is used and the merge request is created.
CI_MERGE_REQUEST_PROJECT_PATHThe path of the project of the merge request if the pipelines are for merge requests (for example namespace/awesome-project). Available only if only: [merge_requests] or rules syntax is used and the merge request is created.
CI_MERGE_REQUEST_PROJECT_URLThe URL of the project of the merge request if the pipelines are for merge requests (for example http://192.168.10.15:3000/namespace/awesome-project). Available only if only: [merge_requests] or rules syntax is used and the merge request is created.
CI_MERGE_REQUEST_REF_PATHThe ref path of the merge request if the pipelines are for merge requests. (for example refs/merge-requests/1/head). Available only if only: [merge_requests] or rules syntax is used and the merge request is created.
CI_MERGE_REQUEST_SOURCE_BRANCH_NAMEThe source branch name of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] or rules syntax is used and the merge request is created.
CI_MERGE_REQUEST_SOURCE_BRANCH_SHAThe HEAD SHA of the source branch of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] or rules syntax is used, the merge request is created, and the pipeline is a merged result pipeline. 
CI_MERGE_REQUEST_SOURCE_PROJECT_IDThe ID of the source project of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] or rules syntax is used and the merge request is created.
CI_MERGE_REQUEST_SOURCE_PROJECT_PATHThe path of the source project of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] or rules syntax is used and the merge request is created.
CI_MERGE_REQUEST_SOURCE_PROJECT_URLThe URL of the source project of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] or rules syntax is used and the merge request is created.
CI_MERGE_REQUEST_TARGET_BRANCH_NAMEThe target branch name of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] or rules syntax is used and the merge request is created.
CI_MERGE_REQUEST_TARGET_BRANCH_SHAThe HEAD SHA of the target branch of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] or rules syntax is used, the merge request is created, and the pipeline is a merged result pipeline. 
CI_MERGE_REQUEST_TITLEThe title of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] or rules syntax is used and the merge request is created.
CI_MERGE_REQUEST_EVENT_TYPEThe event type of the merge request, if the pipelines are for merge requests. Can be detached, merged_result or merge_train.
CI_MERGE_REQUEST_DIFF_IDThe version of the merge request diff, if the pipelines are for merge requests.
CI_MERGE_REQUEST_DIFF_BASE_SHAThe base SHA of the merge request diff, if the pipelines are for merge requests.
CI_NODE_INDEXIndex of the job in the job set. If the job is not parallelized, this variable is not set.
CI_NODE_TOTALTotal number of instances of this job running in parallel. If the job is not parallelized, this variable is set to 1.
CI_PAGES_DOMAINThe configured domain that hosts GitLab Pages.
CI_PAGES_URLURL to GitLab Pages-built pages. Always belongs to a subdomain of CI_PAGES_DOMAIN.
CI_PIPELINE_IDThe instance-level ID of the current pipeline. This is a unique ID across all projects on GitLab.
CI_PIPELINE_IIDThe project-level IID (internal ID) of the current pipeline. This ID is unique for the current project.
CI_PIPELINE_SOURCEIndicates how the pipeline was triggered. Possible options are: push, web, schedule, api, external, chat, webide, merge_request_event, external_pull_request_event, parent_pipeline, trigger, or pipeline. For pipelines created before GitLab 9.5, this is displayed as unknown.
CI_PIPELINE_TRIGGEREDThe flag to indicate that job was triggered.
CI_PIPELINE_URLPipeline details URL.
CI_PROJECT_CONFIG_PATHThe CI configuration path for the project.
CI_PROJECT_DIRThe 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_IDThe unique ID of the current project that GitLab CI/CD uses internally.
CI_PROJECT_NAMEThe name of the directory for the project that is 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_NAMESPACEThe project namespace (username or group name) that is being built.
CI_PROJECT_ROOT_NAMESPACEThe root project namespace (username or group name) that is being built. For example, if CI_PROJECT_NAMESPACE is root-group/child-group/grandchild-group, CI_PROJECT_ROOT_NAMESPACE would be root-group.
CI_PROJECT_PATHThe namespace with project name.
CI_PROJECT_PATH_SLUG$CI_PROJECT_PATH in lowercase and with everything except 0-9 and a-z replaced with -. Use in URLs and domain names.
CI_PROJECT_REPOSITORY_LANGUAGESComma-separated, lowercase list of the languages used in the repository (for example ruby,javascript,html,css).
CI_PROJECT_TITLEThe human-readable project name as displayed in the GitLab web interface.
CI_PROJECT_URLThe HTTP(S) address to access project.
CI_PROJECT_VISIBILITYThe project visibility (internal, private, public).
CI_REGISTRYIf the Container Registry is enabled it returns the address of the GitLab Container Registry. This variable includes a :port value if one has been specified in the registry configuration.
CI_REGISTRY_IMAGEIf the Container Registry is enabled for the project it returns the address of the registry tied to the specific project.
CI_REGISTRY_PASSWORDThe password to use to push containers to the GitLab Container Registry, for the current project.
CI_REGISTRY_USERThe username to use to push containers to the GitLab Container Registry, for the current project.
CI_REPOSITORY_URLThe URL to clone the Git repository.
CI_RUNNER_DESCRIPTIONThe description of the runner as saved in GitLab.
CI_RUNNER_EXECUTABLE_ARCHThe OS/architecture of the GitLab Runner executable (note that this is not necessarily the same as the environment of the executor).
CI_RUNNER_IDThe unique ID of runner being used.
CI_RUNNER_REVISIONGitLab Runner revision that is executing the current job.
CI_RUNNER_SHORT_TOKENFirst eight characters of the runner’s token used to authenticate new job requests. Used as the runner’s unique ID.
CI_RUNNER_TAGSThe defined runner tags.
CI_RUNNER_VERSIONGitLab Runner version that is executing the current job.
CI_SERVERMark that job is executed in CI environment.
CI_SERVER_URLThe base URL of the GitLab instance, including protocol and port (like https://gitlab.example.com:8080).
CI_SERVER_HOSTHost component of the GitLab instance URL, without protocol and port (like gitlab.example.com).
CI_SERVER_PORTPort component of the GitLab instance URL, without host and protocol (like 3000).
CI_SERVER_PROTOCOLProtocol component of the GitLab instance URL, without host and port (like https).
CI_SERVER_NAMEThe name of CI server that is used to coordinate jobs.
CI_SERVER_REVISIONGitLab revision that is used to schedule jobs.
CI_SERVER_VERSIONGitLab version that is used to schedule jobs.
CI_SERVER_VERSION_MAJORGitLab version major component.
CI_SERVER_VERSION_MINORGitLab version minor component.
CI_SERVER_VERSION_PATCHGitLab version patch component.
CI_SHARED_ENVIRONMENTMarks 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.
GITLAB_CIMark that job is executed in GitLab CI/CD environment.
GITLAB_FEATURESThe comma separated list of licensed features available for your instance and plan.
GITLAB_USER_EMAILThe email of the user who started the job.
GITLAB_USER_IDThe ID of the user who started the job.
GITLAB_USER_LOGINThe login username of the user who started the job.
GITLAB_USER_NAMEThe real name of the user who started the job.