gitlab CI/CD 中预设变量 .gitlab-ci.yml 的预定义变量 - 日理万妓 2022-11-25 05:24 468阅读 0赞 GitLab CI / CD具有一组[默认的预定义变量][Link 1] ,您可以使用它们而无需任何其他说明。您可以呼叫问题编号,用户名,分支名称,管道和提交ID等。 GitLab为Runner的本地环境提供了预定义的环境变量。 GitLab读取`.gitlab-ci.yml`文件并将信息发送到Runner,在此处公开变量。然后,运行程序运行脚本命令。 您可以选择现有的预定义变量之一,以由Runner输出。 本示例说明如何使用预定义变量输出作业的阶段`CI_JOB_STAGE`。 在`.gitlab-ci.yml`文件中,从脚本中调用变量。确保使用正确的[语法][Link 2]。 test_variable: stage: test script: - echo $CI_JOB_STAGE 中文 <table> <thead> <tr> <th style="text-align:left;">变量</th> <th style="text-align:left;">gitlab</th> <th style="text-align:left;">runner</th> <th style="text-align:left;">描述</th> </tr> </thead> <tbody> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CHAT_CHANNEL</code></td> <td style="border-color:#dfdfdf;text-align:left;">10.6</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">触发<a href="https://docs.gitlab.com/ee/ci/chatops/README.html" rel="nofollow">ChatOps</a>命令的 源聊天通道</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CHAT_INPUT</code></td> <td style="border-color:#dfdfdf;text-align:left;">10.6</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">在<a href="https://docs.gitlab.com/ee/ci/chatops/README.html" rel="nofollow">ChatOps</a>命令中 传递的其他参数</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI</code></td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">0.4</td> <td style="border-color:#dfdfdf;text-align:left;">标记作业在CI环境中执行</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_API_V4_URL</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.7</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">GitLab API v4根URL</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_BUILDS_DIR</code></td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">11.10</td> <td style="border-color:#dfdfdf;text-align:left;">执行构建的顶级目录。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_COMMIT_BEFORE_SHA</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.2</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">先前的最新提交存在于分支中。始终<code>0000000000000000000000000000000000000000</code>处于合并请求的管道中。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_COMMIT_DESCRIPTION</code></td> <td style="border-color:#dfdfdf;text-align:left;">10.8</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">提交的描述:如果标题少于100个字符,则不带第一行的消息;在其他情况下为完整消息。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_COMMIT_MESSAGE</code></td> <td style="border-color:#dfdfdf;text-align:left;">10.8</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">完整的提交消息。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_COMMIT_REF_NAME</code></td> <td style="border-color:#dfdfdf;text-align:left;">9.0</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">构建项目的分支或标记名称</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_COMMIT_REF_PROTECTED</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.11</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;"><code>true</code>如果作业在受保护的引用上运行,<code>false</code>则不是</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_COMMIT_REF_SLUG</code></td> <td style="border-color:#dfdfdf;text-align:left;">9.0</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;"><code>$CI_COMMIT_REF_NAME</code>小写,缩短为63个字节,并与一切除了<code>0-9</code>和<code>a-z</code>与更换<code>-</code>。没有前导/尾随<code>-</code>。在URL,主机名和域名中使用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_COMMIT_SHA</code></td> <td style="border-color:#dfdfdf;text-align:left;">9.0</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">为其构建项目的提交修订</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_COMMIT_SHORT_SHA</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.7</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">的前八个字符 <code>CI_COMMIT_SHA</code></td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_COMMIT_BRANCH</code></td> <td style="border-color:#dfdfdf;text-align:left;">12.6</td> <td style="border-color:#dfdfdf;text-align:left;">0.5</td> <td style="border-color:#dfdfdf;text-align:left;">提交分支名称。仅在建立分支时显示。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_COMMIT_TAG</code></td> <td style="border-color:#dfdfdf;text-align:left;">9.0</td> <td style="border-color:#dfdfdf;text-align:left;">0.5</td> <td style="border-color:#dfdfdf;text-align:left;">提交标记名称。仅在构建标签时显示。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_COMMIT_TITLE</code></td> <td style="border-color:#dfdfdf;text-align:left;">10.8</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">提交的标题-消息的第一行</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_CONCURRENT_ID</code></td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">11.10</td> <td style="border-color:#dfdfdf;text-align:left;">单个执行程序中生成执行的唯一ID。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_CONCURRENT_PROJECT_ID</code></td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">11.10</td> <td style="border-color:#dfdfdf;text-align:left;">单个执行程序和项目中的构建执行的唯一ID。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_CONFIG_PATH</code></td> <td style="border-color:#dfdfdf;text-align:left;">9.4</td> <td style="border-color:#dfdfdf;text-align:left;">0.5</td> <td style="border-color:#dfdfdf;text-align:left;">CI配置文件的路径。默认为<code>.gitlab-ci.yml</code></td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_DEBUG_TRACE</code></td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">1.7</td> <td style="border-color:#dfdfdf;text-align:left;">是否启用 <a href="https://docs.gitlab.com/ee/ci/variables/README.html#debug-logging" rel="nofollow">调试日志记录(跟踪)</a></td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_DEFAULT_BRANCH</code></td> <td style="border-color:#dfdfdf;text-align:left;">12.4</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">项目的默认分支的名称。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_DEPLOY_PASSWORD</code></td> <td style="border-color:#dfdfdf;text-align:left;">10.8</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;"><a href="https://docs.gitlab.com/ee/user/project/deploy_tokens/index.html#gitlab-deploy-token" rel="nofollow">GitLab Deploy令牌的</a>身份验证密码,仅在项目具有相关性时才提供。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_DEPLOY_USER</code></td> <td style="border-color:#dfdfdf;text-align:left;">10.8</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;"><a href="https://docs.gitlab.com/ee/user/project/deploy_tokens/index.html#gitlab-deploy-token" rel="nofollow">GitLab Deploy令牌的</a>身份验证用户名,仅在项目具有相关性时才存在。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_DISPOSABLE_ENVIRONMENT</code></td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">10.1</td> <td style="border-color:#dfdfdf;text-align:left;">标记该作业是在一次性环境中执行的(仅为该作业创建并在执行后处置/销毁的事物- <code>shell</code>和之外的所有执行者<code>ssh</code>)。如果环境是一次性的,则将其设置为true,否则将完全未定义。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_ENVIRONMENT_NAME</code></td> <td style="border-color:#dfdfdf;text-align:left;">8.15</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">该作业的环境名称。仅在<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#environmentname" rel="nofollow"><code>environment:name</code></a>设置时存在。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_ENVIRONMENT_SLUG</code></td> <td style="border-color:#dfdfdf;text-align:left;">8.15</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">环境名称的简化版本,适合包含在DNS,URL,Kubernetes标签等中。仅在<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#environmentname" rel="nofollow"><code>environment:name</code></a>设置时存在。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_ENVIRONMENT_URL</code></td> <td style="border-color:#dfdfdf;text-align:left;">9.3</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">该作业的环境的URL。仅在<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#environmenturl" rel="nofollow"><code>environment:url</code></a>设置时存在。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_EXTERNAL_PULL_REQUEST_IID</code></td> <td style="border-color:#dfdfdf;text-align:left;">12.3</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/ci_cd_for_external_repos/index.html#pipelines-for-external-pull-requests" rel="nofollow">管道用于外部请求,</a>则来自GitHub的请求请求ID 。仅当使用<code>only: [external_pull_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法且拉取请求处于打开状态时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_EXTERNAL_PULL_REQUEST_SOURCE_REPOSITORY</code></td> <td style="border-color:#dfdfdf;text-align:left;">13.3</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/ci_cd_for_external_repos/index.html#pipelines-for-external-pull-requests" rel="nofollow">管道用于外部</a>请求,则请求请求的源存储库名称。仅当使用<code>only: [external_pull_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法且拉取请求处于打开状态时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_EXTERNAL_PULL_REQUEST_TARGET_REPOSITORY</code></td> <td style="border-color:#dfdfdf;text-align:left;">13.3</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/ci_cd_for_external_repos/index.html#pipelines-for-external-pull-requests" rel="nofollow">管道用于外部</a>请求,则请求请求的目标存储库名称。仅当使用<code>only: [external_pull_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法且拉取请求处于打开状态时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_NAME</code></td> <td style="border-color:#dfdfdf;text-align:left;">12.3</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/ci_cd_for_external_repos/index.html#pipelines-for-external-pull-requests" rel="nofollow">管道用于外部</a>请求,则请求请求的源分支名称。仅当使用<code>only: [external_pull_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法且拉取请求处于打开状态时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_SHA</code></td> <td style="border-color:#dfdfdf;text-align:left;">12.3</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/ci_cd_for_external_repos/index.html#pipelines-for-external-pull-requests" rel="nofollow">管道用于外部</a>请求,则请求请求的源分支的HEAD SHA 。仅当使用<code>only: [external_pull_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法且拉取请求处于打开状态时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_NAME</code></td> <td style="border-color:#dfdfdf;text-align:left;">12.3</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/ci_cd_for_external_repos/index.html#pipelines-for-external-pull-requests" rel="nofollow">管道用于外部</a>请求,则请求请求的目标分支名称。仅当使用<code>only: [external_pull_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法且拉取请求处于打开状态时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_SHA</code></td> <td style="border-color:#dfdfdf;text-align:left;">12.3</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/ci_cd_for_external_repos/index.html#pipelines-for-external-pull-requests" rel="nofollow">管道用于外部</a>请求,则请求请求目标分支的HEAD SHA 。仅当使用<code>only: [external_pull_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法且拉取请求处于打开状态时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_HAS_OPEN_REQUIREMENTS</code></td> <td style="border-color:#dfdfdf;text-align:left;">13.1</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;"><code>true</code>仅当管道的项目有任何开放<a href="https://docs.gitlab.com/ee/user/project/requirements/index.html" rel="nofollow">需求</a>时才包含在值中。如果管道项目没有开放要求,则不包括在内。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_JOB_ID</code></td> <td style="border-color:#dfdfdf;text-align:left;">9.0</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">GitLab CI / CD在内部使用的当前作业的唯一ID</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_JOB_IMAGE</code></td> <td style="border-color:#dfdfdf;text-align:left;">12.9</td> <td style="border-color:#dfdfdf;text-align:left;">12.9</td> <td style="border-color:#dfdfdf;text-align:left;">运行CI作业的图像的名称</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_JOB_MANUAL</code></td> <td style="border-color:#dfdfdf;text-align:left;">8.12</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">指示作业已手动启动的标志</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_JOB_NAME</code></td> <td style="border-color:#dfdfdf;text-align:left;">9.0</td> <td style="border-color:#dfdfdf;text-align:left;">0.5</td> <td style="border-color:#dfdfdf;text-align:left;">在中定义的作业名称 <code>.gitlab-ci.yml</code></td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_JOB_STAGE</code></td> <td style="border-color:#dfdfdf;text-align:left;">9.0</td> <td style="border-color:#dfdfdf;text-align:left;">0.5</td> <td style="border-color:#dfdfdf;text-align:left;">在中定义的阶段名称 <code>.gitlab-ci.yml</code></td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_JOB_TOKEN</code></td> <td style="border-color:#dfdfdf;text-align:left;">9.0</td> <td style="border-color:#dfdfdf;text-align:left;">1.2</td> <td style="border-color:#dfdfdf;text-align:left;">用于通过<a href="https://docs.gitlab.com/ee/user/packages/container_registry/index.html" rel="nofollow">GitLab容器注册表</a>进行身份验证,下载<a href="https://docs.gitlab.com/ee/user/project/new_ci_build_permissions_model.html#dependent-repositories" rel="nofollow">从属存储库</a>以及访问<a href="https://docs.gitlab.com/ee/user/infrastructure/index.html#gitlab-managed-terraform-state" rel="nofollow">GitLab管理的Terraform状态的</a>令牌。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_JOB_JWT</code></td> <td style="border-color:#dfdfdf;text-align:left;">12.10</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">RS256 JSON Web令牌,可用于与支持JWT身份验证的第三方系统进行身份验证,例如<a href="https://docs.gitlab.com/ee/ci/examples/authenticating-with-hashicorp-vault" rel="nofollow">HashiCorp的Vault</a>。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_JOB_URL</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.1</td> <td style="border-color:#dfdfdf;text-align:left;">0.5</td> <td style="border-color:#dfdfdf;text-align:left;">职位详情网址</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_KUBERNETES_ACTIVE</code></td> <td style="border-color:#dfdfdf;text-align:left;">13.0</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;"><code>true</code>仅当管道具有可用于部署的Kubernetes集群时,才包含在值中。如果没有群集,则不包括在内。可作为替代<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#onlykubernetesexceptkubernetes" rel="nofollow"><code>only:kubernetes</code>/<code>except:kubernetes</code></a>与<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rulesif" rel="nofollow"><code>rules:if</code></a></td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_MERGE_REQUEST_ASSIGNEES</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.9</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">管道用于合并请求</a>,则该合并请求的受让人的用户名列表用逗号分隔。仅当使用<code>only: [merge_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法并且创建合并请求时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_MERGE_REQUEST_ID</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.6</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">合并请求的项目级别ID。仅当<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">管道用于合并请求</a>并且创建<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">合并请求</a>时才可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_MERGE_REQUEST_IID</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.6</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">合并请求的实例级IID。仅<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">当管道用于合并请求</a>并且创建<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">合并请求</a>时才可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_MERGE_REQUEST_LABELS</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.9</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">管道用于合并请求</a>,则合并请求的逗号分隔标签名称。仅当使用<code>only: [merge_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法并且创建合并请求时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_MERGE_REQUEST_MILESTONE</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.9</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">管道用于合并请求</a>,则合并请求的里程碑标题。仅当使用<code>only: [merge_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法并且创建合并请求时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_MERGE_REQUEST_PROJECT_ID</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.6</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">管道用于合并请求</a>,则合并请求的项目的ID 。仅当使用<code>only: [merge_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法并且创建合并请求时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_MERGE_REQUEST_PROJECT_PATH</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.6</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">管道用于合并请求</a>(例如<code>namespace/awesome-project</code>),则合并请求的项目路径。仅当使用<code>only: [merge_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法并且创建合并请求时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_MERGE_REQUEST_PROJECT_URL</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.6</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">管道用于合并请求</a>(例如<code>http://192.168.10.15:3000/namespace/awesome-project</code>),则合并请求项目的URL 。仅当使用<code>only: [merge_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法并且创建合并请求时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_MERGE_REQUEST_REF_PATH</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.6</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">管道用于合并请求</a>,则合并请求的ref路径。(例如<code>refs/merge-requests/1/head</code>)。仅当使用<code>only: [merge_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法并且创建合并请求时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_MERGE_REQUEST_SOURCE_BRANCH_NAME</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.6</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">管道用于合并请求</a>,则合并请求的源分支名称。仅当使用<code>only: [merge_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法并且创建合并请求时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_MERGE_REQUEST_SOURCE_BRANCH_SHA</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.9</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">管道用于合并请求</a>,则合并请求的源分支的HEAD SHA 。仅在使用<code>only: [merge_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法,创建合并请求且管道为<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/pipelines_for_merged_results/index.html" rel="nofollow">合并结果管道时</a>可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_MERGE_REQUEST_SOURCE_PROJECT_ID</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.6</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">管道用于合并请求</a>,则合并请求的源项目的ID 。仅当使用<code>only: [merge_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法并且创建合并请求时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_MERGE_REQUEST_SOURCE_PROJECT_PATH</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.6</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">管道用于合并请求</a>,则合并请求的源项目的路径。仅当使用<code>only: [merge_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法并且创建合并请求时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_MERGE_REQUEST_SOURCE_PROJECT_URL</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.6</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">管道用于合并请求</a>,则合并请求的源项目的URL 。仅当使用<code>only: [merge_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法并且创建合并请求时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_MERGE_REQUEST_TARGET_BRANCH_NAME</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.6</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">管道用于合并请求</a>,则合并请求的目标分支名称。仅当使用<code>only: [merge_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法并且创建合并请求时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_MERGE_REQUEST_TARGET_BRANCH_SHA</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.9</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">管道用于合并请求</a>,则合并请求的目标分支的HEAD SHA 。仅在使用<code>only: [merge_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法,创建合并请求且管道为<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/pipelines_for_merged_results/index.html" rel="nofollow">合并结果管道时</a>可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_MERGE_REQUEST_TITLE</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.9</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">如果<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">管道用于合并请求</a>,则合并请求的标题。仅当使用<code>only: [merge_requests]</code>或<a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a>语法并且创建合并请求时可用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_MERGE_REQUEST_EVENT_TYPE</code></td> <td style="border-color:#dfdfdf;text-align:left;">12.3</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">合并请求的事件类型(如果<a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">管道用于合并请求)</a>。可能是<code>detached</code>,<code>merged_result</code>或<code>merge_train</code>。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_NODE_INDEX</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.5</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">作业在作业集中的索引。如果作业未并行化,则不会设置此变量。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_NODE_TOTAL</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.5</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">并行运行的此作业的实例总数。如果作业未并行化,则此变量设置为<code>1</code>。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_PAGES_DOMAIN</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.8</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">托管GitLab页面的已配置域。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_PAGES_URL</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.8</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">GitLab页面构建页面的URL。始终属于的子域<code>CI_PAGES_DOMAIN</code>。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_PIPELINE_ID</code></td> <td style="border-color:#dfdfdf;text-align:left;">8.10</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">GitLab CI / CD在内部使用的当前管道的唯一ID</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_PIPELINE_IID</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.0</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">当前管道的唯一ID范围为项目</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_PIPELINE_SOURCE</code></td> <td style="border-color:#dfdfdf;text-align:left;">10.0</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">指示如何触发管道。可能的选项有:<code>push</code>,<code>web</code>,<code>schedule</code>,<code>api</code>,<code>external</code>,<code>chat</code>,<code>webide</code>,<code>merge_request_event</code>,<code>external_pull_request_event</code>,<code>parent_pipeline</code>,<a href="https://docs.gitlab.com/ee/ci/triggers/README.html#authentication-tokens" rel="nofollow"><code>trigger</code>,或<code>pipeline</code></a>(更名为<code>cross_project_pipeline</code>自13.0)。对于在GitLab 9.5之前创建的管道,它将显示为<code>unknown</code>。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_PIPELINE_TRIGGERED</code></td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">指示已<a href="https://docs.gitlab.com/ee/ci/triggers/README.html" rel="nofollow">触发</a>作业的标志</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_PIPELINE_URL</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.1</td> <td style="border-color:#dfdfdf;text-align:left;">0.5</td> <td style="border-color:#dfdfdf;text-align:left;">管道详细资料网址</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_PROJECT_DIR</code></td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">克隆存储库以及运行作业的完整路径。如果设置了GitLab Runner <code>builds_dir</code>参数,则相对于的值设置此变量<code>builds_dir</code>。有关更多信息,请参见GitLab Runner的<a href="https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runners-section" rel="nofollow">高级配置</a>。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_PROJECT_ID</code></td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">GitLab CI / CD在内部使用的当前项目的唯一ID</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_PROJECT_NAME</code></td> <td style="border-color:#dfdfdf;text-align:left;">8.10</td> <td style="border-color:#dfdfdf;text-align:left;">0.5</td> <td style="border-color:#dfdfdf;text-align:left;">当前正在构建的项目的目录名称。例如,如果项目的URL是<code>gitlab.example.com/group-name/project-1</code>,该<code>CI_PROJECT_NAME</code>会<code>project-1</code>。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_PROJECT_NAMESPACE</code></td> <td style="border-color:#dfdfdf;text-align:left;">8.10</td> <td style="border-color:#dfdfdf;text-align:left;">0.5</td> <td style="border-color:#dfdfdf;text-align:left;">当前正在构建的项目名称空间(用户名或组名)</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_PROJECT_ROOT_NAMESPACE</code></td> <td style="border-color:#dfdfdf;text-align:left;">13.2</td> <td style="border-color:#dfdfdf;text-align:left;">0.5</td> <td style="border-color:#dfdfdf;text-align:left;">当前正在构建的<strong>根</strong>项目名称空间(用户名或组名)。例如,如果<code>CI_PROJECT_NAME</code>是<code>root-group/child-group/grandchild-group</code>,<code>CI_PROJECT_ROOT_NAMESPACE</code>是<code>root-group</code>。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_PROJECT_PATH</code></td> <td style="border-color:#dfdfdf;text-align:left;">8.10</td> <td style="border-color:#dfdfdf;text-align:left;">0.5</td> <td style="border-color:#dfdfdf;text-align:left;">具有项目名称的名称空间</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_PROJECT_PATH_SLUG</code></td> <td style="border-color:#dfdfdf;text-align:left;">9.3</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;"><code>$CI_PROJECT_PATH</code>小写并与除一切<code>0-9</code>,并<code>a-z</code>代之以<code>-</code>。在URL和域名中使用。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_PROJECT_REPOSITORY_LANGUAGES</code></td> <td style="border-color:#dfdfdf;text-align:left;">12.3</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">信息库中使用的语言的逗号分隔小写列表(例如<code>ruby,javascript,html,css</code>)</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_PROJECT_TITLE</code></td> <td style="border-color:#dfdfdf;text-align:left;">12.4</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">可读的项目名称,显示在GitLab Web界面中。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_PROJECT_URL</code></td> <td style="border-color:#dfdfdf;text-align:left;">8.10</td> <td style="border-color:#dfdfdf;text-align:left;">0.5</td> <td style="border-color:#dfdfdf;text-align:left;">访问项目的HTTP(S)地址</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_PROJECT_VISIBILITY</code></td> <td style="border-color:#dfdfdf;text-align:left;">10.3</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">项目可见性(内部,私人,公共)</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_REGISTRY</code></td> <td style="border-color:#dfdfdf;text-align:left;">8.10</td> <td style="border-color:#dfdfdf;text-align:left;">0.5</td> <td style="border-color:#dfdfdf;text-align:left;">如果启用了Container Registry,它将返回GitLab的Container Registry的地址。<code>:port</code>如果在注册表配置中指定了一个变量,则该变量将包含一个值。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_REGISTRY_IMAGE</code></td> <td style="border-color:#dfdfdf;text-align:left;">8.10</td> <td style="border-color:#dfdfdf;text-align:left;">0.5</td> <td style="border-color:#dfdfdf;text-align:left;">如果为项目启用了容器注册表,则它将返回绑定到特定项目的注册表地址</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_REGISTRY_PASSWORD</code></td> <td style="border-color:#dfdfdf;text-align:left;">9.0</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">用于将容器推送到当前项目的GitLab容器注册表的密码。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_REGISTRY_USER</code></td> <td style="border-color:#dfdfdf;text-align:left;">9.0</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">用于将容器推送到当前项目的GitLab容器注册表的用户名。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_REPOSITORY_URL</code></td> <td style="border-color:#dfdfdf;text-align:left;">9.0</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">克隆Git存储库的URL</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_RUNNER_DESCRIPTION</code></td> <td style="border-color:#dfdfdf;text-align:left;">8.10</td> <td style="border-color:#dfdfdf;text-align:left;">0.5</td> <td style="border-color:#dfdfdf;text-align:left;">保存在GitLab中的跑步者的描述</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_RUNNER_EXECUTABLE_ARCH</code></td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">10.6</td> <td style="border-color:#dfdfdf;text-align:left;">GitLab Runner可执行文件的操作系统/体系结构(请注意,它不一定与执行程序的环境相同)</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_RUNNER_ID</code></td> <td style="border-color:#dfdfdf;text-align:left;">8.10</td> <td style="border-color:#dfdfdf;text-align:left;">0.5</td> <td style="border-color:#dfdfdf;text-align:left;">正在使用的跑步者的唯一ID</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_RUNNER_REVISION</code></td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">10.6</td> <td style="border-color:#dfdfdf;text-align:left;">正在执行当前作业的GitLab Runner版本</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_RUNNER_SHORT_TOKEN</code></td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">12.3</td> <td style="border-color:#dfdfdf;text-align:left;">GitLab Runner令牌的前八个字符用于验证新的作业请求。用作跑步者的唯一ID</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_RUNNER_TAGS</code></td> <td style="border-color:#dfdfdf;text-align:left;">8.10</td> <td style="border-color:#dfdfdf;text-align:left;">0.5</td> <td style="border-color:#dfdfdf;text-align:left;">定义的运行器标签</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_RUNNER_VERSION</code></td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">10.6</td> <td style="border-color:#dfdfdf;text-align:left;">正在执行当前作业的GitLab Runner版本</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_SERVER</code></td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">标记作业在CI环境中执行</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_SERVER_URL</code></td> <td style="border-color:#dfdfdf;text-align:left;">12.7</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">GitLab实例的基本URL,包括协议和端口(如<code>https://gitlab.example.com:8080</code>)</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_SERVER_HOST</code></td> <td style="border-color:#dfdfdf;text-align:left;">12.1</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">GitLab实例URL的主机组件,不带协议和端口(如<code>gitlab.example.com</code>)</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_SERVER_PORT</code></td> <td style="border-color:#dfdfdf;text-align:left;">12.8</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">GitLab实例URL的端口组件,不包含主机和协议(例如<code>3000</code>)</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_SERVER_PROTOCOL</code></td> <td style="border-color:#dfdfdf;text-align:left;">12.8</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">GitLab实例URL的协议组件,不带主机和端口(例如<code>https</code>)</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_SERVER_NAME</code></td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">用于协调作业的CI服务器的名称</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_SERVER_REVISION</code></td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">用于计划作业的GitLab修订版</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_SERVER_VERSION</code></td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">用于计划作业的GitLab版本</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_SERVER_VERSION_MAJOR</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.4</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">GitLab版本主要组件</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_SERVER_VERSION_MINOR</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.4</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">GitLab版本次要组件</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_SERVER_VERSION_PATCH</code></td> <td style="border-color:#dfdfdf;text-align:left;">11.4</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">GitLab版本补丁组件</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>CI_SHARED_ENVIRONMENT</code></td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">10.1</td> <td style="border-color:#dfdfdf;text-align:left;">标记作业是在共享环境中执行的(在CI调用(例如executor <code>shell</code>或<code>ssh</code>executor)中持续存在的内容)。如果共享环境,则将其设置为true,否则将完全未定义。</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>GITLAB_CI</code></td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">标记作业在GitLab CI / CD环境中执行</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>GITLAB_FEATURES</code></td> <td style="border-color:#dfdfdf;text-align:left;">10.6</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">以逗号分隔的实例和计划可用的许可功能列表</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>GITLAB_USER_EMAIL</code></td> <td style="border-color:#dfdfdf;text-align:left;">8.12</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">开始工作的用户的电子邮件</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>GITLAB_USER_ID</code></td> <td style="border-color:#dfdfdf;text-align:left;">8.12</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">开始工作的用户的ID</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>GITLAB_USER_LOGIN</code></td> <td style="border-color:#dfdfdf;text-align:left;">10.0</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">开始工作的用户的登录用户名</td> </tr> <tr> <td style="border-color:#dfdfdf;text-align:left;"><code>GITLAB_USER_NAME</code></td> <td style="border-color:#dfdfdf;text-align:left;">10.0</td> <td style="border-color:#dfdfdf;text-align:left;">所有</td> <td style="border-color:#dfdfdf;text-align:left;">开始工作的用户的真实姓名</td> </tr> </tbody> </table> 英文 <table> <thead> <tr> <th style="width:235px;">Variable</th> <th style="width:106px;">GitLab</th> <th>Runner</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td style="width:235px;"><code>CHAT_CHANNEL</code></td> <td style="width:106px;">10.6</td> <td>all</td> <td>Source chat channel which triggered the <a href="https://docs.gitlab.com/ee/ci/chatops/README.html" rel="nofollow">ChatOps</a> command</td> </tr> <tr> <td style="width:235px;"><code>CHAT_INPUT</code></td> <td style="width:106px;">10.6</td> <td>all</td> <td>Additional arguments passed in the <a href="https://docs.gitlab.com/ee/ci/chatops/README.html" rel="nofollow">ChatOps</a> command</td> </tr> <tr> <td style="width:235px;"><code>CI</code></td> <td style="width:106px;">all</td> <td>0.4</td> <td>Mark that job is executed in CI environment</td> </tr> <tr> <td style="width:235px;"><code>CI_API_V4_URL</code></td> <td style="width:106px;">11.7</td> <td>all</td> <td>The GitLab API v4 root URL</td> </tr> <tr> <td style="width:235px;"><code>CI_BUILDS_DIR</code></td> <td style="width:106px;">all</td> <td>11.10</td> <td>Top-level directory where builds are executed.</td> </tr> <tr> <td style="width:235px;"><code>CI_COMMIT_BEFORE_SHA</code></td> <td style="width:106px;">11.2</td> <td>all</td> <td>The previous latest commit present on a branch. Is always <code>0000000000000000000000000000000000000000</code> in pipelines for merge requests.</td> </tr> <tr> <td style="width:235px;"><code>CI_COMMIT_DESCRIPTION</code></td> <td style="width:106px;">10.8</td> <td>all</td> <td>The description of the commit: the message without first line, if the title is shorter than 100 characters; full message in other case.</td> </tr> <tr> <td style="width:235px;"><code>CI_COMMIT_MESSAGE</code></td> <td style="width:106px;">10.8</td> <td>all</td> <td>The full commit message.</td> </tr> <tr> <td style="width:235px;"><code>CI_COMMIT_REF_NAME</code></td> <td style="width:106px;">9.0</td> <td>all</td> <td>The branch or tag name for which project is built</td> </tr> <tr> <td style="width:235px;"><code>CI_COMMIT_REF_PROTECTED</code></td> <td style="width:106px;">11.11</td> <td>all</td> <td><code>true</code> if the job is running on a protected reference, <code>false</code> if not</td> </tr> <tr> <td style="width:235px;"><code>CI_COMMIT_REF_SLUG</code></td> <td style="width:106px;">9.0</td> <td>all</td> <td><code>$CI_COMMIT_REF_NAME</code> lowercased, shortened to 63 bytes, and with everything except <code>0-9</code> and <code>a-z</code> replaced with <code>-</code>. No leading / trailing <code>-</code>. Use in URLs, host names and domain names.</td> </tr> <tr> <td style="width:235px;"><code>CI_COMMIT_SHA</code></td> <td style="width:106px;">9.0</td> <td>all</td> <td>The commit revision for which project is built</td> </tr> <tr> <td style="width:235px;"><code>CI_COMMIT_SHORT_SHA</code></td> <td style="width:106px;">11.7</td> <td>all</td> <td>The first eight characters of <code>CI_COMMIT_SHA</code></td> </tr> <tr> <td style="width:235px;"><code>CI_COMMIT_BRANCH</code></td> <td style="width:106px;">12.6</td> <td>0.5</td> <td>The commit branch name. Present only when building branches.</td> </tr> <tr> <td style="width:235px;"><code>CI_COMMIT_TAG</code></td> <td style="width:106px;">9.0</td> <td>0.5</td> <td>The commit tag name. Present only when building tags.</td> </tr> <tr> <td style="width:235px;"><code>CI_COMMIT_TITLE</code></td> <td style="width:106px;">10.8</td> <td>all</td> <td>The title of the commit - the full first line of the message</td> </tr> <tr> <td style="width:235px;"><code>CI_CONCURRENT_ID</code></td> <td style="width:106px;">all</td> <td>11.10</td> <td>Unique ID of build execution within a single executor.</td> </tr> <tr> <td style="width:235px;"><code>CI_CONCURRENT_PROJECT_ID</code></td> <td style="width:106px;">all</td> <td>11.10</td> <td>Unique ID of build execution within a single executor and project.</td> </tr> <tr> <td style="width:235px;"><code>CI_CONFIG_PATH</code></td> <td style="width:106px;">9.4</td> <td>0.5</td> <td>The path to CI configuration file. Defaults to <code>.gitlab-ci.yml</code></td> </tr> <tr> <td style="width:235px;"><code>CI_DEBUG_TRACE</code></td> <td style="width:106px;">all</td> <td>1.7</td> <td>Whether <a href="https://docs.gitlab.com/ee/ci/variables/README.html#debug-logging" rel="nofollow">debug logging (tracing)</a> is enabled</td> </tr> <tr> <td style="width:235px;"><code>CI_DEFAULT_BRANCH</code></td> <td style="width:106px;">12.4</td> <td>all</td> <td>The name of the default branch for the project.</td> </tr> <tr> <td style="width:235px;"><code>CI_DEPLOY_PASSWORD</code></td> <td style="width:106px;">10.8</td> <td>all</td> <td>Authentication password of the <a href="https://docs.gitlab.com/ee/user/project/deploy_tokens/index.html#gitlab-deploy-token" rel="nofollow">GitLab Deploy Token</a>, only present if the Project has one related.</td> </tr> <tr> <td style="width:235px;"><code>CI_DEPLOY_USER</code></td> <td style="width:106px;">10.8</td> <td>all</td> <td>Authentication username of the <a href="https://docs.gitlab.com/ee/user/project/deploy_tokens/index.html#gitlab-deploy-token" rel="nofollow">GitLab Deploy Token</a>, only present if the Project has one related.</td> </tr> <tr> <td style="width:235px;"><code>CI_DISPOSABLE_ENVIRONMENT</code></td> <td style="width:106px;">all</td> <td>10.1</td> <td>Marks 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 <code>shell</code> and <code>ssh</code>). If the environment is disposable, it is set to true, otherwise it is not defined at all.</td> </tr> <tr> <td style="width:235px;"><code>CI_ENVIRONMENT_NAME</code></td> <td style="width:106px;">8.15</td> <td>all</td> <td>The name of the environment for this job. Only present if <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#environmentname" rel="nofollow"><code>environment:name</code></a> is set.</td> </tr> <tr> <td style="width:235px;"><code>CI_ENVIRONMENT_SLUG</code></td> <td style="width:106px;">8.15</td> <td>all</td> <td>A simplified version of the environment name, suitable for inclusion in DNS, URLs, Kubernetes labels, etc. Only present if <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#environmentname" rel="nofollow"><code>environment:name</code></a> is set.</td> </tr> <tr> <td style="width:235px;"><code>CI_ENVIRONMENT_URL</code></td> <td style="width:106px;">9.3</td> <td>all</td> <td>The URL of the environment for this job. Only present if <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#environmenturl" rel="nofollow"><code>environment:url</code></a> is set.</td> </tr> <tr> <td style="width:235px;"><code>CI_EXTERNAL_PULL_REQUEST_IID</code></td> <td style="width:106px;">12.3</td> <td>all</td> <td>Pull Request ID from GitHub if the <a href="https://docs.gitlab.com/ee/ci/ci_cd_for_external_repos/index.html#pipelines-for-external-pull-requests" rel="nofollow">pipelines are for external pull requests</a>. Available only if <code>only: [external_pull_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the pull request is open.</td> </tr> <tr> <td style="width:235px;"><code>CI_EXTERNAL_PULL_REQUEST_SOURCE_REPOSITORY</code></td> <td style="width:106px;">13.3</td> <td>all</td> <td>The source repository name of the pull request if <a href="https://docs.gitlab.com/ee/ci/ci_cd_for_external_repos/index.html#pipelines-for-external-pull-requests" rel="nofollow">the pipelines are for external pull requests</a>. Available only if <code>only: [external_pull_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the pull request is open.</td> </tr> <tr> <td style="width:235px;"><code>CI_EXTERNAL_PULL_REQUEST_TARGET_REPOSITORY</code></td> <td style="width:106px;">13.3</td> <td>all</td> <td>The target repository name of the pull request if <a href="https://docs.gitlab.com/ee/ci/ci_cd_for_external_repos/index.html#pipelines-for-external-pull-requests" rel="nofollow">the pipelines are for external pull requests</a>. Available only if <code>only: [external_pull_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the pull request is open.</td> </tr> <tr> <td style="width:235px;"><code>CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_NAME</code></td> <td style="width:106px;">12.3</td> <td>all</td> <td>The source branch name of the pull request if <a href="https://docs.gitlab.com/ee/ci/ci_cd_for_external_repos/index.html#pipelines-for-external-pull-requests" rel="nofollow">the pipelines are for external pull requests</a>. Available only if <code>only: [external_pull_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the pull request is open.</td> </tr> <tr> <td style="width:235px;"><code>CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_SHA</code></td> <td style="width:106px;">12.3</td> <td>all</td> <td>The HEAD SHA of the source branch of the pull request if <a href="https://docs.gitlab.com/ee/ci/ci_cd_for_external_repos/index.html#pipelines-for-external-pull-requests" rel="nofollow">the pipelines are for external pull requests</a>. Available only if <code>only: [external_pull_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the pull request is open.</td> </tr> <tr> <td style="width:235px;"><code>CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_NAME</code></td> <td style="width:106px;">12.3</td> <td>all</td> <td>The target branch name of the pull request if <a href="https://docs.gitlab.com/ee/ci/ci_cd_for_external_repos/index.html#pipelines-for-external-pull-requests" rel="nofollow">the pipelines are for external pull requests</a>. Available only if <code>only: [external_pull_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the pull request is open.</td> </tr> <tr> <td style="width:235px;"><code>CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_SHA</code></td> <td style="width:106px;">12.3</td> <td>all</td> <td>The HEAD SHA of the target branch of the pull request if <a href="https://docs.gitlab.com/ee/ci/ci_cd_for_external_repos/index.html#pipelines-for-external-pull-requests" rel="nofollow">the pipelines are for external pull requests</a>. Available only if <code>only: [external_pull_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the pull request is open.</td> </tr> <tr> <td style="width:235px;"><code>CI_HAS_OPEN_REQUIREMENTS</code></td> <td style="width:106px;">13.1</td> <td>all</td> <td>Included with the value <code>true</code> only if the pipeline’s project has any open <a href="https://docs.gitlab.com/ee/user/project/requirements/index.html" rel="nofollow">requirements</a>. Not included if there are no open requirements for the pipeline’s project.</td> </tr> <tr> <td style="width:235px;"><code>CI_JOB_ID</code></td> <td style="width:106px;">9.0</td> <td>all</td> <td>The unique ID of the current job that GitLab CI/CD uses internally</td> </tr> <tr> <td style="width:235px;"><code>CI_JOB_IMAGE</code></td> <td style="width:106px;">12.9</td> <td>12.9</td> <td>The name of the image running the CI job</td> </tr> <tr> <td style="width:235px;"><code>CI_JOB_MANUAL</code></td> <td style="width:106px;">8.12</td> <td>all</td> <td>The flag to indicate that job was manually started</td> </tr> <tr> <td style="width:235px;"><code>CI_JOB_NAME</code></td> <td style="width:106px;">9.0</td> <td>0.5</td> <td>The name of the job as defined in <code>.gitlab-ci.yml</code></td> </tr> <tr> <td style="width:235px;"><code>CI_JOB_STAGE</code></td> <td style="width:106px;">9.0</td> <td>0.5</td> <td>The name of the stage as defined in <code>.gitlab-ci.yml</code></td> </tr> <tr> <td style="width:235px;"><code>CI_JOB_TOKEN</code></td> <td style="width:106px;">9.0</td> <td>1.2</td> <td>Token used for authenticating with the <a href="https://docs.gitlab.com/ee/user/packages/container_registry/index.html" rel="nofollow">GitLab Container Registry</a>, downloading <a href="https://docs.gitlab.com/ee/user/project/new_ci_build_permissions_model.html#dependent-repositories" rel="nofollow">dependent repositories</a>, and accessing <a href="https://docs.gitlab.com/ee/user/infrastructure/index.html#gitlab-managed-terraform-state" rel="nofollow">GitLab-managed Terraform state</a>.</td> </tr> <tr> <td style="width:235px;"><code>CI_JOB_JWT</code></td> <td style="width:106px;">12.10</td> <td>all</td> <td>RS256 JSON web token that can be used for authenticating with third party systems that support JWT authentication, for example <a href="https://docs.gitlab.com/ee/ci/examples/authenticating-with-hashicorp-vault" rel="nofollow">HashiCorp’s Vault</a>.</td> </tr> <tr> <td style="width:235px;"><code>CI_JOB_URL</code></td> <td style="width:106px;">11.1</td> <td>0.5</td> <td>Job details URL</td> </tr> <tr> <td style="width:235px;"><code>CI_KUBERNETES_ACTIVE</code></td> <td style="width:106px;">13.0</td> <td>all</td> <td>Included with the value <code>true</code> 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 <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#onlykubernetesexceptkubernetes" rel="nofollow"><code>only:kubernetes</code>/<code>except:kubernetes</code></a> with <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rulesif" rel="nofollow"><code>rules:if</code></a></td> </tr> <tr> <td style="width:235px;"><code>CI_MERGE_REQUEST_ASSIGNEES</code></td> <td style="width:106px;">11.9</td> <td>all</td> <td>Comma-separated list of username(s) of assignee(s) for the merge request if <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">the pipelines are for merge requests</a>. Available only if <code>only: [merge_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the merge request is created.</td> </tr> <tr> <td style="width:235px;"><code>CI_MERGE_REQUEST_ID</code></td> <td style="width:106px;">11.6</td> <td>all</td> <td>The project-level ID of the merge request. Only available if <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">the pipelines are for merge requests</a> and the merge request is created.</td> </tr> <tr> <td style="width:235px;"><code>CI_MERGE_REQUEST_IID</code></td> <td style="width:106px;">11.6</td> <td>all</td> <td>The instance-level IID of the merge request. Only available If <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">the pipelines are for merge requests</a> and the merge request is created.</td> </tr> <tr> <td style="width:235px;"><code>CI_MERGE_REQUEST_LABELS</code></td> <td style="width:106px;">11.9</td> <td>all</td> <td>Comma-separated label names of the merge request if <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">the pipelines are for merge requests</a>. Available only if <code>only: [merge_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the merge request is created.</td> </tr> <tr> <td style="width:235px;"><code>CI_MERGE_REQUEST_MILESTONE</code></td> <td style="width:106px;">11.9</td> <td>all</td> <td>The milestone title of the merge request if <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">the pipelines are for merge requests</a>. Available only if <code>only: [merge_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the merge request is created.</td> </tr> <tr> <td style="width:235px;"><code>CI_MERGE_REQUEST_PROJECT_ID</code></td> <td style="width:106px;">11.6</td> <td>all</td> <td>The ID of the project of the merge request if <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">the pipelines are for merge requests</a>. Available only if <code>only: [merge_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the merge request is created.</td> </tr> <tr> <td style="width:235px;"><code>CI_MERGE_REQUEST_PROJECT_PATH</code></td> <td style="width:106px;">11.6</td> <td>all</td> <td>The path of the project of the merge request if <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">the pipelines are for merge requests</a> (e.g. <code>namespace/awesome-project</code>). Available only if <code>only: [merge_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the merge request is created.</td> </tr> <tr> <td style="width:235px;"><code>CI_MERGE_REQUEST_PROJECT_URL</code></td> <td style="width:106px;">11.6</td> <td>all</td> <td>The URL of the project of the merge request if <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">the pipelines are for merge requests</a> (e.g. <code>http://192.168.10.15:3000/namespace/awesome-project</code>). Available only if <code>only: [merge_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the merge request is created.</td> </tr> <tr> <td style="width:235px;"><code>CI_MERGE_REQUEST_REF_PATH</code></td> <td style="width:106px;">11.6</td> <td>all</td> <td>The ref path of the merge request if <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">the pipelines are for merge requests</a>. (e.g. <code>refs/merge-requests/1/head</code>). Available only if <code>only: [merge_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the merge request is created.</td> </tr> <tr> <td style="width:235px;"><code>CI_MERGE_REQUEST_SOURCE_BRANCH_NAME</code></td> <td style="width:106px;">11.6</td> <td>all</td> <td>The source branch name of the merge request if <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">the pipelines are for merge requests</a>. Available only if <code>only: [merge_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the merge request is created.</td> </tr> <tr> <td style="width:235px;"><code>CI_MERGE_REQUEST_SOURCE_BRANCH_SHA</code></td> <td style="width:106px;">11.9</td> <td>all</td> <td>The HEAD SHA of the source branch of the merge request if <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">the pipelines are for merge requests</a>. Available only if <code>only: [merge_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used, the merge request is created, and the pipeline is a <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/pipelines_for_merged_results/index.html" rel="nofollow">merged result pipeline</a>. </td> </tr> <tr> <td style="width:235px;"><code>CI_MERGE_REQUEST_SOURCE_PROJECT_ID</code></td> <td style="width:106px;">11.6</td> <td>all</td> <td>The ID of the source project of the merge request if <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">the pipelines are for merge requests</a>. Available only if <code>only: [merge_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the merge request is created.</td> </tr> <tr> <td style="width:235px;"><code>CI_MERGE_REQUEST_SOURCE_PROJECT_PATH</code></td> <td style="width:106px;">11.6</td> <td>all</td> <td>The path of the source project of the merge request if <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">the pipelines are for merge requests</a>. Available only if <code>only: [merge_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the merge request is created.</td> </tr> <tr> <td style="width:235px;"><code>CI_MERGE_REQUEST_SOURCE_PROJECT_URL</code></td> <td style="width:106px;">11.6</td> <td>all</td> <td>The URL of the source project of the merge request if <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">the pipelines are for merge requests</a>. Available only if <code>only: [merge_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the merge request is created.</td> </tr> <tr> <td style="width:235px;"><code>CI_MERGE_REQUEST_TARGET_BRANCH_NAME</code></td> <td style="width:106px;">11.6</td> <td>all</td> <td>The target branch name of the merge request if <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">the pipelines are for merge requests</a>. Available only if <code>only: [merge_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the merge request is created.</td> </tr> <tr> <td style="width:235px;"><code>CI_MERGE_REQUEST_TARGET_BRANCH_SHA</code></td> <td style="width:106px;">11.9</td> <td>all</td> <td>The HEAD SHA of the target branch of the merge request if <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">the pipelines are for merge requests</a>. Available only if <code>only: [merge_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used, the merge request is created, and the pipeline is a <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/pipelines_for_merged_results/index.html" rel="nofollow">merged result pipeline</a>. </td> </tr> <tr> <td style="width:235px;"><code>CI_MERGE_REQUEST_TITLE</code></td> <td style="width:106px;">11.9</td> <td>all</td> <td>The title of the merge request if <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">the pipelines are for merge requests</a>. Available only if <code>only: [merge_requests]</code> or <a href="https://docs.gitlab.com/ee/ci/yaml/README.html#rules" rel="nofollow"><code>rules</code></a> syntax is used and the merge request is created.</td> </tr> <tr> <td style="width:235px;"><code>CI_MERGE_REQUEST_EVENT_TYPE</code></td> <td style="width:106px;">12.3</td> <td>all</td> <td>The event type of the merge request, if <a href="https://docs.gitlab.com/ee/ci/merge_request_pipelines/index.html" rel="nofollow">the pipelines are for merge requests</a>. Can be <code>detached</code>, <code>merged_result</code> or <code>merge_train</code>.</td> </tr> <tr> <td style="width:235px;"><code>CI_NODE_INDEX</code></td> <td style="width:106px;">11.5</td> <td>all</td> <td>Index of the job in the job set. If the job is not parallelized, this variable is not set.</td> </tr> <tr> <td style="width:235px;"><code>CI_NODE_TOTAL</code></td> <td style="width:106px;">11.5</td> <td>all</td> <td>Total number of instances of this job running in parallel. If the job is not parallelized, this variable is set to <code>1</code>.</td> </tr> <tr> <td style="width:235px;"><code>CI_PAGES_DOMAIN</code></td> <td style="width:106px;">11.8</td> <td>all</td> <td>The configured domain that hosts GitLab Pages.</td> </tr> <tr> <td style="width:235px;"><code>CI_PAGES_URL</code></td> <td style="width:106px;">11.8</td> <td>all</td> <td>URL to GitLab Pages-built pages. Always belongs to a subdomain of <code>CI_PAGES_DOMAIN</code>.</td> </tr> <tr> <td style="width:235px;"><code>CI_PIPELINE_ID</code></td> <td style="width:106px;">8.10</td> <td>all</td> <td>The unique ID of the current pipeline that GitLab CI/CD uses internally</td> </tr> <tr> <td style="width:235px;"><code>CI_PIPELINE_IID</code></td> <td style="width:106px;">11.0</td> <td>all</td> <td>The unique ID of the current pipeline scoped to project</td> </tr> <tr> <td style="width:235px;"><code>CI_PIPELINE_SOURCE</code></td> <td style="width:106px;">10.0</td> <td>all</td> <td>Indicates how the pipeline was triggered. Possible options are: <code>push</code>, <code>web</code>, <code>schedule</code>, <code>api</code>, <code>external</code>, <code>chat</code>, <code>webide</code>, <code>merge_request_event</code>, <code>external_pull_request_event</code>, <code>parent_pipeline</code>, <a href="https://docs.gitlab.com/ee/ci/triggers/README.html#authentication-tokens" rel="nofollow"><code>trigger</code>, or <code>pipeline</code></a> (renamed to <code>cross_project_pipeline</code> since 13.0). For pipelines created before GitLab 9.5, this will show as <code>unknown</code>.</td> </tr> <tr> <td style="width:235px;"><code>CI_PIPELINE_TRIGGERED</code></td> <td style="width:106px;">all</td> <td>all</td> <td>The flag to indicate that job was <a href="https://docs.gitlab.com/ee/ci/triggers/README.html" rel="nofollow">triggered</a></td> </tr> <tr> <td style="width:235px;"><code>CI_PIPELINE_URL</code></td> <td style="width:106px;">11.1</td> <td>0.5</td> <td>Pipeline details URL</td> </tr> <tr> <td style="width:235px;"><code>CI_PROJECT_DIR</code></td> <td style="width:106px;">all</td> <td>all</td> <td>The full path where the repository is cloned and where the job is run. If the GitLab Runner <code>builds_dir</code> parameter is set, this variable is set relative to the value of <code>builds_dir</code>. For more information, see <a href="https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runners-section" rel="nofollow">Advanced configuration</a> for GitLab Runner.</td> </tr> <tr> <td style="width:235px;"><code>CI_PROJECT_ID</code></td> <td style="width:106px;">all</td> <td>all</td> <td>The unique ID of the current project that GitLab CI/CD uses internally</td> </tr> <tr> <td style="width:235px;"><code>CI_PROJECT_NAME</code></td> <td style="width:106px;">8.10</td> <td>0.5</td> <td>The name of the directory for the project that is currently being built. For example, if the project URL is <code>gitlab.example.com/group-name/project-1</code>, the <code>CI_PROJECT_NAME</code> would be <code>project-1</code>.</td> </tr> <tr> <td style="width:235px;"><code>CI_PROJECT_NAMESPACE</code></td> <td style="width:106px;">8.10</td> <td>0.5</td> <td>The project namespace (username or group name) that is currently being built</td> </tr> <tr> <td style="width:235px;"><code>CI_PROJECT_ROOT_NAMESPACE</code></td> <td style="width:106px;">13.2</td> <td>0.5</td> <td>The <strong>root</strong> project namespace (username or group name) that is currently being built. For example, if <code>CI_PROJECT_NAME</code> is <code>root-group/child-group/grandchild-group</code>, <code>CI_PROJECT_ROOT_NAMESPACE</code> would be <code>root-group</code>.</td> </tr> <tr> <td style="width:235px;"><code>CI_PROJECT_PATH</code></td> <td style="width:106px;">8.10</td> <td>0.5</td> <td>The namespace with project name</td> </tr> <tr> <td style="width:235px;"><code>CI_PROJECT_PATH_SLUG</code></td> <td style="width:106px;">9.3</td> <td>all</td> <td><code>$CI_PROJECT_PATH</code> lowercased and with everything except <code>0-9</code> and <code>a-z</code> replaced with <code>-</code>. Use in URLs and domain names.</td> </tr> <tr> <td style="width:235px;"><code>CI_PROJECT_REPOSITORY_LANGUAGES</code></td> <td style="width:106px;">12.3</td> <td>all</td> <td>Comma-separated, lowercased list of the languages used in the repository (e.g. <code>ruby,javascript,html,css</code>)</td> </tr> <tr> <td style="width:235px;"><code>CI_PROJECT_TITLE</code></td> <td style="width:106px;">12.4</td> <td>all</td> <td>The human-readable project name as displayed in the GitLab web interface.</td> </tr> <tr> <td style="width:235px;"><code>CI_PROJECT_URL</code></td> <td style="width:106px;">8.10</td> <td>0.5</td> <td>The HTTP(S) address to access project</td> </tr> <tr> <td style="width:235px;"><code>CI_PROJECT_VISIBILITY</code></td> <td style="width:106px;">10.3</td> <td>all</td> <td>The project visibility (internal, private, public)</td> </tr> <tr> <td style="width:235px;"><code>CI_REGISTRY</code></td> <td style="width:106px;">8.10</td> <td>0.5</td> <td>If the Container Registry is enabled it returns the address of GitLab’s Container Registry. This variable will include a <code>:port</code> value if one has been specified in the registry configuration.</td> </tr> <tr> <td style="width:235px;"><code>CI_REGISTRY_IMAGE</code></td> <td style="width:106px;">8.10</td> <td>0.5</td> <td>If the Container Registry is enabled for the project it returns the address of the registry tied to the specific project</td> </tr> <tr> <td style="width:235px;"><code>CI_REGISTRY_PASSWORD</code></td> <td style="width:106px;">9.0</td> <td>all</td> <td>The password to use to push containers to the GitLab Container Registry, for the current project.</td> </tr> <tr> <td style="width:235px;"><code>CI_REGISTRY_USER</code></td> <td style="width:106px;">9.0</td> <td>all</td> <td>The username to use to push containers to the GitLab Container Registry, for the current project.</td> </tr> <tr> <td style="width:235px;"><code>CI_REPOSITORY_URL</code></td> <td style="width:106px;">9.0</td> <td>all</td> <td>The URL to clone the Git repository</td> </tr> <tr> <td style="width:235px;"><code>CI_RUNNER_DESCRIPTION</code></td> <td style="width:106px;">8.10</td> <td>0.5</td> <td>The description of the runner as saved in GitLab</td> </tr> <tr> <td style="width:235px;"><code>CI_RUNNER_EXECUTABLE_ARCH</code></td> <td style="width:106px;">all</td> <td>10.6</td> <td>The OS/architecture of the GitLab Runner executable (note that this is not necessarily the same as the environment of the executor)</td> </tr> <tr> <td style="width:235px;"><code>CI_RUNNER_ID</code></td> <td style="width:106px;">8.10</td> <td>0.5</td> <td>The unique ID of runner being used</td> </tr> <tr> <td style="width:235px;"><code>CI_RUNNER_REVISION</code></td> <td style="width:106px;">all</td> <td>10.6</td> <td>GitLab Runner revision that is executing the current job</td> </tr> <tr> <td style="width:235px;"><code>CI_RUNNER_SHORT_TOKEN</code></td> <td style="width:106px;">all</td> <td>12.3</td> <td>First eight characters of GitLab Runner’s token used to authenticate new job requests. Used as Runner’s unique ID</td> </tr> <tr> <td style="width:235px;"><code>CI_RUNNER_TAGS</code></td> <td style="width:106px;">8.10</td> <td>0.5</td> <td>The defined runner tags</td> </tr> <tr> <td style="width:235px;"><code>CI_RUNNER_VERSION</code></td> <td style="width:106px;">all</td> <td>10.6</td> <td>GitLab Runner version that is executing the current job</td> </tr> <tr> <td style="width:235px;"><code>CI_SERVER</code></td> <td style="width:106px;">all</td> <td>all</td> <td>Mark that job is executed in CI environment</td> </tr> <tr> <td style="width:235px;"><code>CI_SERVER_URL</code></td> <td style="width:106px;">12.7</td> <td>all</td> <td>The base URL of the GitLab instance, including protocol and port (like <code>https://gitlab.example.com:8080</code>)</td> </tr> <tr> <td style="width:235px;"><code>CI_SERVER_HOST</code></td> <td style="width:106px;">12.1</td> <td>all</td> <td>Host component of the GitLab instance URL, without protocol and port (like <code>gitlab.example.com</code>)</td> </tr> <tr> <td style="width:235px;"><code>CI_SERVER_PORT</code></td> <td style="width:106px;">12.8</td> <td>all</td> <td>Port component of the GitLab instance URL, without host and protocol (like <code>3000</code>)</td> </tr> <tr> <td style="width:235px;"><code>CI_SERVER_PROTOCOL</code></td> <td style="width:106px;">12.8</td> <td>all</td> <td>Protocol component of the GitLab instance URL, without host and port (like <code>https</code>)</td> </tr> <tr> <td style="width:235px;"><code>CI_SERVER_NAME</code></td> <td style="width:106px;">all</td> <td>all</td> <td>The name of CI server that is used to coordinate jobs</td> </tr> <tr> <td style="width:235px;"><code>CI_SERVER_REVISION</code></td> <td style="width:106px;">all</td> <td>all</td> <td>GitLab revision that is used to schedule jobs</td> </tr> <tr> <td style="width:235px;"><code>CI_SERVER_VERSION</code></td> <td style="width:106px;">all</td> <td>all</td> <td>GitLab version that is used to schedule jobs</td> </tr> <tr> <td style="width:235px;"><code>CI_SERVER_VERSION_MAJOR</code></td> <td style="width:106px;">11.4</td> <td>all</td> <td>GitLab version major component</td> </tr> <tr> <td style="width:235px;"><code>CI_SERVER_VERSION_MINOR</code></td> <td style="width:106px;">11.4</td> <td>all</td> <td>GitLab version minor component</td> </tr> <tr> <td style="width:235px;"><code>CI_SERVER_VERSION_PATCH</code></td> <td style="width:106px;">11.4</td> <td>all</td> <td>GitLab version patch component</td> </tr> <tr> <td style="width:235px;"><code>CI_SHARED_ENVIRONMENT</code></td> <td style="width:106px;">all</td> <td>10.1</td> <td>Marks that the job is executed in a shared environment (something that is persisted across CI invocations like <code>shell</code> or <code>ssh</code> executor). If the environment is shared, it is set to true, otherwise it is not defined at all.</td> </tr> <tr> <td style="width:235px;"><code>GITLAB_CI</code></td> <td style="width:106px;">all</td> <td>all</td> <td>Mark that job is executed in GitLab CI/CD environment</td> </tr> <tr> <td style="width:235px;"><code>GITLAB_FEATURES</code></td> <td style="width:106px;">10.6</td> <td>all</td> <td>The comma separated list of licensed features available for your instance and plan</td> </tr> <tr> <td style="width:235px;"><code>GITLAB_USER_EMAIL</code></td> <td style="width:106px;">8.12</td> <td>all</td> <td>The email of the user who started the job</td> </tr> <tr> <td style="width:235px;"><code>GITLAB_USER_ID</code></td> <td style="width:106px;">8.12</td> <td>all</td> <td>The ID of the user who started the job</td> </tr> <tr> <td style="width:235px;"><code>GITLAB_USER_LOGIN</code></td> <td style="width:106px;">10.0</td> <td>all</td> <td>The login username of the user who started the job</td> </tr> <tr> <td style="width:235px;"><code>GITLAB_USER_NAME</code></td> <td style="width:106px;">10.0</td> <td>all</td> <td>The real name of the user who started the job</td> </tr> </tbody> </table> [https://docs.gitlab.com/ee/ci/variables/predefined\_variables.html][Link 1] [Link 1]: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html [Link 2]: https://docs.gitlab.com/ee/ci/variables/README.html#syntax-of-environment-variables-in-job-scripts
还没有评论,来说两句吧...