198.md 12.8 KB
Newer Older
Lab机器人's avatar
readme  
Lab机器人 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
# GitLab CI/CD

> 原文:[https://docs.gitlab.com/ee/ci/README.html](https://docs.gitlab.com/ee/ci/README.html)

*   [Overview](#overview)
*   [Getting started](#getting-started)
*   [Concepts](#concepts)
*   [Configuration](#configuration)
*   [Feature set](#feature-set)
*   [Examples](#examples)
*   [Administration](#administration-core-only)
*   [References](#references)
    *   [Why GitLab CI/CD?](#why-gitlab-cicd)
    *   [Breaking changes](#breaking-changes)
        *   [13.0](#130)
        *   [12.0](#120)
        *   [11.0](#110)
        *   [10.0](#100)
        *   [9.0](#90)

# GitLab CI/CD[](#gitlab-cicd "Permalink")

GitLab CI / CD 是 GitLab 内置的工具,用于通过[连续方法](introduction/index.html#introduction-to-cicd-methodologies)进行软件开发:

*   持续集成(CI)
*   连续交付(CD)
*   持续部署(CD)

**注意:**开箱即用的管理系统可以将维护工具链所花费的时间减少 10%或更多. 观看我们的["精通持续软件开发"](https://about.gitlab.com/webcast/mastering-ci-cd/)网络广播,以了解连续方法以及 GitLab 的内置 CI 如何帮助您简化和扩展软件开发.

## Overview[](#overview "Permalink")

持续集成的工作原理是将小的代码块推送到 Git 存储库中托管的应用程序代码库中,并且每次推送时,都要运行脚本管道来构建,测试和验证代码更改,然后再将其合并到主分支中.

持续交付和部署包括进一步的 CI,可在每次推送到存储库默认分支时将应用程序部署到生产环境.

这些方法使您可以在开发周期的早期发现错误和错误,从而确保部署到生产环境的所有代码均符合为应用程序建立的代码标准.

有关这些方法和 GitLab CI / CD 的完整概述,请阅读 GitLab 的 CI / CD [简介](introduction/index.html) .

GitLab CI / CD 的视频演示: [演示:](https://www.youtube.com/watch?v=1iXFbchozdY) GitLab 的 CI / CD.

<figure class="video-container"><iframe src="https://www.youtube.com/embed/1iXFbchozdY" frameborder="0" allowfullscreen=""></iframe></figure>

## Getting started[](#getting-started "Permalink")

GitLab CI / CD 由位于存储库根目录的名为`.gitlab-ci.yml`的文件配置. 该文件创建[管道](pipelines/index.html) ,该[管道](pipelines/index.html)运行以更改存储库中的代码. 管道包含一个或多个顺序运行的阶段,每个阶段可以包含一个或多个并行运行的作业. 这些作业(或脚本)由[GitLab Runner](https://docs.gitlab.com/runner/)代理执行.

要开始使用 GitLab CI / CD,我们建议您通读以下文档:

*   [How GitLab CI/CD works](introduction/index.html#how-gitlab-cicd-works).
*   [Fundamental pipeline architectures](pipelines/pipeline_architectures.html).
*   [GitLab CI/CD basic workflow](introduction/index.html#basic-cicd-workflow).
*   [Step-by-step guide for writing `.gitlab-ci.yml` for the first time](../user/project/pages/getting_started/pages_from_scratch.html).

如果您要从其他 CI / CD 工具迁移,请查看我们方便的参考资料:

*   [Migrating from CircleCI](migration/circleci.html)
*   [Migrating from Jenkins](jenkins/index.html)

您也可以使用 UI 中提供的[`.gitlab-ci.yml`模板](https://gitlab.com/gitlab-org/gitlab-foss/tree/master/lib/gitlab/ci/templates)之一来开始使用. 您可以通过创建新文件,选择适合您的应用程序的模板并根据需要进行调整来使用它们:

[![Use a `.gitlab-ci.yml` template](img/e006fccde54b694d8c0f506a675942e0.png)](img/add_file_template_11_10.png)

有关更广泛的概述,请参阅《 [CI / CD 入门](quick_start/README.html)指南》.

熟悉 GitLab CI / CD 的工作原理后,请参阅[`.gitlab-ci.yml`完整参考,](yaml/README.html)以获取可以设置和使用的所有属性.

**注意:** GitLab CI / CD 和[共享运行](runners/README.html#shared-runners)器在 GitLab.com 中启用,并且对所有用户可用,仅限于[用户的管道配额](../user/gitlab_com/index.html#shared-runners) .

## Concepts[](#concepts "Permalink")

GitLab CI / CD 使用许多概念来描述和运行您的构建和部署.

| Concept | Description |
| --- | --- |
| [Pipelines](pipelines/index.html) | Structure your CI/CD process through pipelines. |
| [Environment variables](variables/README.html) | 根据变量/值键对重用值. |
| [Environments](environments/index.html) | 将您的应用程序部署到不同的环境(例如,登台,生产). |
| [Job artifacts](pipelines/job_artifacts.html) | 输出,使用和重用作业工件. |
| [Cache dependencies](caching/index.html) | 缓存您的依赖项以加快执行速度. |
| [GitLab Runner](https://docs.gitlab.com/runner/) | 配置自己的 GitLab 运行程序以执行脚本. |

## Configuration[](#configuration "Permalink")

GitLab CI / CD 支持多种配置选项:

| Configuration | Description |
| --- | --- |
| [Schedule pipelines](pipelines/schedules.html) | 计划管道以根据需要运行. |
| [Custom path for `.gitlab-ci.yml`](pipelines/settings.html#custom-ci-configuration-path) | 为 CI / CD 配置文件定义自定义路径. |
| [Git submodules for CI/CD](git_submodules.html) | 配置作业以使用 Git 子模块. |
| [SSH keys for CI/CD](ssh_keys/README.html) | 在 CI 管道中使用 SSH 密钥. |
| [Pipeline triggers](triggers/README.html) | 通过 API 触发管道. |
| [Pipelines for Merge Requests](merge_request_pipelines/index.html) | 设计用于在合并请求中运行管道的管道结构. |
| [Integrate with Kubernetes clusters](../user/project/clusters/index.html) | 将您的项目连接到 Google Kubernetes Engine(GKE)或现有的 Kubernetes 集群. |
| [Optimize GitLab and Runner for large repositories](large_repositories/index.html) | 处理大型存储库的推荐策略. |
| [`.gitlab-ci.yml` full reference](yaml/README.html) | 您可以在 GitLab CI / CD 中使用的所有属性. |

请注意,某些操作只能根据[用户](../user/permissions.html#gitlab-cicd-permissions)[作业](../user/permissions.html#job-permissions)权限执行.

## Feature set[](#feature-set "Permalink")

使用庞大的 GitLab CI / CD 可以轻松地针对特定目的进行配置. 根据 DevOps 阶段,其功能集在下表中列出.

| Feature | Description |
| --- | --- |
| **Configure** |   |
| [Auto DevOps](../topics/autodevops/index.html) | 设置应用的整个生命周期. |
| [ChatOps](chatops/README.html) | 从聊天中触发 CI 作业,并将结果发送回通道. |
| **Verify** |   |
| [Browser Performance Testing](../user/project/merge_requests/browser_performance_testing.html) | 快速确定即将发生的代码更改对浏览器性能的影响. |
| [Load Performance Testing](../user/project/merge_requests/load_performance_testing.html) | 快速确定未决代码更改对服务器性能的影响. |
| [CI services](services/README.html) | 将 Docker 容器与您的基本映像链接起来. |
| [Code Quality](../user/project/merge_requests/code_quality.html) | 分析您的源代码质量. |
| [GitLab CI/CD for external repositories](ci_cd_for_external_repos/index.html) | 结合使用 GitHub 和 Bitbucket Cloud 中的存储库,获得 GitLab CI / CD 的优势. |
| [Interactive Web Terminals](interactive_web_terminal/index.html) | 打开一个交互式 Web 终端以调试正在运行的作业. |
| [JUnit tests](junit_test_reports.html) | 直接在合并请求中识别脚本失败. |
| [Using Docker images](docker/using_docker_images.html) | 将 GitLab 和 GitLab Runner 与 Docker 结合使用来构建和测试应用程序. |
| **Release** |   |
| [Auto Deploy](../topics/autodevops/stages.html#auto-deploy) | 将您的应用程序部署到 Kubernetes 集群中的生产环境. |
| [Building Docker images](docker/using_docker_build.html) | 使用 GitLab CI / CD 维护基于 Docker 的项目. |
| [Canary Deployments](../user/project/canary_deployments.html) | 仅将功能部件运送到一部分吊舱中,并让一定比例的用户群访问临时部署的功能部件. |
| [Deploy Boards](../user/project/deploy_boards.html) | 检查 Kubernetes 上运行的每个 CI / CD 环境的当前运行状况和状态. |
| [Feature Flags](../operations/feature_flags.html) | 在功能标记后部署功能. |
| [GitLab Pages](../user/project/pages/index.html) | 部署静态网站. |
| [GitLab Releases](../user/project/releases/index.html) | 将发行说明添加到 Git 标签. |
| [Review Apps](review_apps/index.html) | 配置 GitLab CI / CD 预览代码更改. |
| [Cloud deployment](cloud_deployment/index.html) | 将您的应用程序部署到主要的云提供商. |
| **Secure** |   |
| [Container Scanning](../user/application_security/container_scanning/index.html) | 检查您的 Docker 容器是否存在已知漏洞. |
| [Dependency Scanning](../user/application_security/dependency_scanning/index.html) | 分析您的依赖项是否存在已知漏洞. |
| [License Compliance](../user/compliance/license_compliance/index.html) | 在项目依赖项中搜索其许可证. |
| [Security Test reports](../user/application_security/index.html) | 检查应用程序漏洞. |

## Examples[](#examples "Permalink")

在" [CI 实例"](examples/README.html)页面上查找示例项目代码和教程,以将 GitLab CI / CD 与各种应用程序框架,语言和平台结合使用.

GitLab 还提供了[示例项目,这些项目已](https://gitlab.com/gitlab-examples)预先配置为使用 GitLab CI / CD.

## Administration[](#administration-core-only "Permalink")

作为 GitLab 管理员,您可以将 GitLab CI / CD 的默认行为更改为:

*   An [entire GitLab instance](../user/admin_area/settings/continuous_integration.html).
*   具体项目,使用[管道设置](pipelines/settings.html) .

也可以看看:

*   [How to enable or disable GitLab CI/CD](enable_or_disable_ci.html).
*   Other [CI administration settings](../administration/index.html#continuous-integration-settings).

## References[](#references "Permalink")

### Why GitLab CI/CD?[](#why-gitlab-cicd "Permalink")

学习更多关于:

*   [Why you might chose GitLab CI/CD](https://about.gitlab.com/blog/2016/10/17/gitlab-ci-oohlala/).
*   [Reasons you might migrate from another platform](https://about.gitlab.com/blog/2016/07/22/building-our-web-app-on-gitlab-ci/).
*   [5 Teams that made the switch to GitLab CI/CD](https://about.gitlab.com/blog/2019/04/25/5-teams-that-made-the-switch-to-gitlab-ci-cd/)

另请参阅[为什么选择 CI / CD?](https://docs.google.com/presentation/d/1OGgk2Tcxbpl7DJaIOzCX4Vqg3dlwfELC3u2jEeCBbDk) 介绍.

### Breaking changes[](#breaking-changes "Permalink")

随着 GitLab CI / CD 的发展,必须进行一些重大更改. 这些是:

#### 13.0[](#130 "Permalink")

*   [Remove Backported `os.Expand`](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4915)
*   [Remove Fedora 29 package support](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/16158)
*   [Remove macOS 32-bit support](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/25466)
*   [Removed `debug/jobs/list?v=1` endpoint](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/6361)
*   [Remove support for array of strings when defining services for Docker executor](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4922)
*   [Remove `--docker-services` flag on register command](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/6404)
*   [Remove legacy build directory caching](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4180)
*   [Remove `FF_USE_LEGACY_VOLUMES_MOUNTING_ORDER` feature flag](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/6581)
*   [Remove support for Windows Server 1803](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/6553)

#### 12.0[](#120 "Permalink")

*   [Use refspec to clone/fetch Git repository](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4069).
*   [Old cache configuration](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4070).
*   [Old metrics server configuration](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4072).
*   [Remove `FF_K8S_USE_ENTRYPOINT_OVER_COMMAND`](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4073).
*   [Remove Linux distributions that reach EOL](https://gitlab.com/gitlab-org/gitlab-runner/-/merge_requests/1130).
*   [Update command line API for helper images](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4013).
*   [Remove old `git clean` flow](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4175).

#### 11.0[](#110 "Permalink")

*   没有重大变化.

#### 10.0[](#100 "Permalink")

*   没有重大变化.

#### 9.0[](#90 "Permalink")

*   [为 GitLab 9.0 重命名 CI 变量](variables/deprecated_variables.html#gitlab-90-renamed-variables) . 了解不建议使用的 CI 变量以及在 GitLab 9.0+中应使用的内容.
*   [新的 CI 作业权限模型](../user/project/new_ci_build_permissions_model.html) . 查看 GitLab 8.12 中的更改及其对工作的影响. 有一种新方法可以访问作业中的 Git 子模块和 LFS 对象.