README.md 16 KB
Newer Older
1
2
---
comments: false
3
description: "Learn how to use GitLab CI/CD, the GitLab built-in Continuous Integration, Continuous Deployment, and Continuous Delivery toolset to build, test, and deploy your application."
4
5
---

6
# GitLab Continuous Integration (GitLab CI/CD)
Douwe Maan's avatar
Douwe Maan committed
7

Evan Read's avatar
Evan Read committed
8
9
10
11
GitLab provides tools for continuously integrating and delivering code.

Within the [entire DevOps lifecycle](../README.md#the-entire-devops-lifecycle), GitLab CI/CD spans
the [Verify (CI)](../README.md#verify) and [Release (CD)](../README.md#release) stages.
Achilleas Pipinellis's avatar
Achilleas Pipinellis committed
12

Evan Read's avatar
Evan Read committed
13
## Overview
Achilleas Pipinellis's avatar
Achilleas Pipinellis committed
14

Evan Read's avatar
Evan Read committed
15
CI/CD is a vast area, so GitLab provides documentation for all levels of expertise. Consult the following table to find the right documentation for you:
Achilleas Pipinellis's avatar
Achilleas Pipinellis committed
16

Evan Read's avatar
Evan Read committed
17
18
19
20
21
22
| Level of expertise                  | Resource                                                                                                                                              |
|:------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------|
| New to the concepts of CI and CD    | For a high-level overview, see the [GitLab Continuous Integration & Delivery](https://about.gitlab.com/product/continuous-integration/) product page. |
| Familiar with the purpose of CI/CD  | Delve into GitLab CI/CD by continuing down the page, starting with our [introduction](#introduction).                                                 |
| Familiar with GitLab CI/CD concepts | After getting familiar with GitLab CI/CD, let us walk you through a simple example in our [quick start guide](quick_start/README.md).                 |
| A GitLab CI/CD expert               | Jump straight to our [`.gitlab.yml`](yaml/README.md) reference.                                                                                       |
23

Evan Read's avatar
Evan Read committed
24
## Introduction
25

Evan Read's avatar
Evan Read committed
26
The following introduces the process of continuous integration (CI) and continuous delivery (CD):
27

Evan Read's avatar
Evan Read committed
28
![Pipeline graph](img/cicd_pipeline_infograph.png)
29

Evan Read's avatar
Evan Read committed
30
In this illustration:
Achilleas Pipinellis's avatar
Achilleas Pipinellis committed
31

Evan Read's avatar
Evan Read committed
32
33
34
35
36
37
38
- New code is combined with existing code through a commit to a project's [repository](../user/project/repository/index.md).
- The newly combined code is sent to a CI [pipeline](pipelines.md) where:
  - The code is [built](../user/project/pipelines/job_artifacts.md).
  - Unit and integration tests are run over the built code.
- Assuming the build and tests are successful, a CD pipeline is triggered to allow for:
  - Review using [Review Apps](review_apps/index.md).
  - Deploying to configured [environments](environments.md).
39

Evan Read's avatar
Evan Read committed
40
The benefits of CI/CD are vast, allowing automation to be an integral part of your workflow for testing, building, deploying, and monitoring your code.
Achilleas Pipinellis's avatar
Achilleas Pipinellis committed
41

Evan Read's avatar
Evan Read committed
42
43
Because CI and CD with GitLab is broad topic with many possibilities, the rest of this section provides
links to topics and resources needed to make use of GitLab CI/CD.
Achilleas Pipinellis's avatar
Achilleas Pipinellis committed
44

Evan Read's avatar
Evan Read committed
45
## Essentials
Achilleas Pipinellis's avatar
Achilleas Pipinellis committed
46

Evan Read's avatar
Evan Read committed
47
The following documentation provides the minimum required knowledge for making use of GitLab CI/CD:
Achilleas Pipinellis's avatar
Achilleas Pipinellis committed
48

Evan Read's avatar
Evan Read committed
49
50
51
52
53
| Topic                                                                   | Description                                              |
|:------------------------------------------------------------------------|:---------------------------------------------------------|
| [Getting started with GitLab CI/CD](quick_start/README.md)              | Outlines the first steps for configuring GitLab CI/CD.   |
| [Introduction to pipelines and jobs](pipelines.md)                      | Provides an overview of GitLab CI/CD and jobs.           |
| [Configuration of your pipelines with `.gitlab-ci.yml`](yaml/README.md) | A comprehensive reference for the `.gitlab-ci.yml` file. |
54

Evan Read's avatar
Evan Read committed
55
56
57
58
NOTE: **Note:**
Familiarity with [GitLab Runner](https://docs.gitlab.com/runner/) is useful because it is
responsible for running the jobs in your CI/CD pipeline. On GitLab.com, shared Runners are enabled
by default so you don't need to set up anything to get started.
Achilleas Pipinellis's avatar
Achilleas Pipinellis committed
59

Evan Read's avatar
Evan Read committed
60
### Auto DevOps
61

Evan Read's avatar
Evan Read committed
62
63
An alternative to manually configuring CI/CD, GitLab supports [Auto DevOps](../topics/autodevops/index.md),
which:
64

Evan Read's avatar
Evan Read committed
65
66
- Provides simplified setup and execution of CI/CD.
- Allows GitLab to automatically detect, build, test, deploy, and monitor your applications.
67

Evan Read's avatar
Evan Read committed
68
## Basic usage
69

Evan Read's avatar
Evan Read committed
70
71
With basic knowledge of how GitLab CI/CD works, the following documentation extends your knowledge
into more features:
72

Evan Read's avatar
Evan Read committed
73
74
75
76
77
78
| Topic                                                                                                  | Description                                                                      |
|:-------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|
| [CI/CD Variables](variables/README.md)                                                                 | How environment variables can be configured and made available in pipelines.     |
| [Where variables can be used](variables/where_variables_can_be_used.md)                                | A deeper look into where and how CI/CD variables can be used.                    |
| [User](../user/permissions.md#gitlab-ci) and [job](../user/permissions.md#job-permissions) permissions | Learn about the access levels a user can have for performing certain CI actions. |
| [Configuring GitLab Runners](runners/README.md)                                                        | Documentation for configuring [GitLab Runner](https://docs.gitlab.com/runner/).  |
79

Evan Read's avatar
Evan Read committed
80
## Advanced usage
81

Evan Read's avatar
Evan Read committed
82
83
Once you get familiar with the basics of GitLab CI/CD, consult the following documentation to make
use of advanced features:
84

Evan Read's avatar
Evan Read committed
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
| Topic                                                                            | Description                                                                                                                  |
|:---------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------|
| [Introduction to environments and deployments](environments.md)                  | Learn how to separate your jobs into environments and use them for different purposes like testing, building and, deploying. |
| [Job artifacts](../user/project/pipelines/job_artifacts.md)                      | Learn about the output of jobs.                                                                                              |
| [Cache dependencies in GitLab CI/CD](caching/index.md)                           | Discover how to speed up pipelines using caching.                                                                            |
| [Using Git submodules with GitLab CI](git_submodules.md)                         | How to run your CI jobs when using Git submodules.                                                                           |
| [Pipelines for merge requests](merge_request_pipelines/index.md)                 | Create pipelines specifically for merge requests.                                                                            |
| [Using SSH keys with GitLab CI/CD](ssh_keys/README.md)                           | Use SSH keys in your build environment.                                                                                      |
| [Triggering pipelines through the API](triggers/README.md)                       | Use the GitLab API to trigger a pipeline.                                                                                    |
| [Pipeline schedules](../user/project/pipelines/schedules.md)                     | Trigger pipelines on a schedule.                                                                                             |
| [Connecting GitLab with a Kubernetes cluster](../user/project/clusters/index.md) | Integrate one or more Kubernetes clusters to your project.                                                                   |
| [Interactive web terminals](interactive_web_terminal/index.md)                   | Open an interactive web terminal to debug the running jobs.                                                                  |

### GitLab Pages

GitLab CI/CD can be used to build and host static websites. For more information, see the
documentation on [GitLab Pages](../user/project/pages/index.md).
Achilleas Pipinellis's avatar
Achilleas Pipinellis committed
102

103
104
## Examples

Evan Read's avatar
Evan Read committed
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
Check out the [GitLab CI/CD examples](examples/README.md) for a collection of tutorials and guides on
setting up your CI/CD pipeline for various programming languages, frameworks, and operating systems.

## Administration

As a GitLab administrator, you can change the default behavior of GitLab CI/CD for:

- An [entire GitLab instance](../user/admin_area/settings/continuous_integration.md).
- Specific projects, using [pipelines settings](../user/project/pipelines/settings.md).

See also:

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

## Using Docker

Docker is commonly used with GitLab CI/CD. Learn more about how to to accomplish this with the following
documentation:

| Topic                                                                    | Description                                                              |
|:-------------------------------------------------------------------------|:-------------------------------------------------------------------------|
| [Using Docker images](docker/using_docker_images.md)                     | Use GitLab and GitLab Runner with Docker to build and test applications. |
| [Building Docker images with GitLab CI/CD](docker/using_docker_build.md) | Maintain Docker-based projects using GitLab CI/CD.                       |

Related topics include:
131

Evan Read's avatar
Evan Read committed
132
133
134
- [Docker integration](docker/README.md).
- [CI services (linked Docker containers)](services/README.md).
- [Setting up GitLab Runner For Continuous Integration](https://about.gitlab.com/2016/03/01/gitlab-runner-with-docker/) (article).
135

Evan Read's avatar
Evan Read committed
136
## Further resources
137

Evan Read's avatar
Evan Read committed
138
This section provides further resources to help you get familiar with GitLab CI/CD.
139

Evan Read's avatar
Evan Read committed
140
### Articles
141

Evan Read's avatar
Evan Read committed
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
The following table provides a list of articles about CI/CD, sorted in reverse chronological order of publish date:

| Publish Date | Article                                                                                                                                                                                                                                       |
|:-------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 2017-07-13   | [Making CI easier with GitLab](https://about.gitlab.com/2017/07/13/making-ci-easier-with-gitlab/).                                                                                                                                            |
| 2017-05-22   | [Fast and natural continuous integration with GitLab CI](https://about.gitlab.com/2017/05/22/fast-and-natural-continuous-integration-with-gitlab-ci/).                                                                                        |
| 2016-11-22   | [Introducing Review Apps](https://about.gitlab.com/2016/11/22/introducing-review-apps/).                                                                                                                                                      |
| 2016-08-26   | [GitLab CI: Deployment & Environments](https://about.gitlab.com/2016/08/26/ci-deployment-and-environments/).                                                                                                                                  |
| 2016-08-05   | [Continuous Integration, Delivery, and Deployment with GitLab](https://about.gitlab.com/2016/08/05/continuous-integration-delivery-and-deployment-with-gitlab/).                                                                              |
| 2016-07-29   | [GitLab CI: Run jobs sequentially, in parallel or build a custom pipeline](https://about.gitlab.com/2016/07/29/the-basics-of-gitlab-ci/).                                                                                                     |
| 2016-06-09   | [Continuous Delivery with GitLab and Convox](https://about.gitlab.com/2016/06/09/continuous-delivery-with-gitlab-and-convox/)                                                                                                                 |
| 2016-05-23   | [GitLab Container Registry](https://about.gitlab.com/2016/05/23/gitlab-container-registry/).                                                                                                                                                  |
| 2016-05-05   | [Getting Started with GitLab and Shippable Continuous Integration](https://about.gitlab.com/2016/05/05/getting-started-gitlab-and-shippable/)                                                                                                 |
| 2016-04-19   | [GitLab Partners with DigitalOcean to make Continuous Integration faster, safer, and more affordable](https://about.gitlab.com/2016/04/19/gitlab-partners-with-digitalocean-to-make-continuous-integration-faster-safer-and-more-affordable/) |
| 2015-03-01   | [Setting up GitLab Runner For Continuous Integration](https://about.gitlab.com/2016/03/01/gitlab-runner-with-docker/).                                                                                                                        |
| 2015-12-14   | [Getting started with GitLab and GitLab CI](https://about.gitlab.com/2015/12/14/getting-started-with-gitlab-and-gitlab-ci/).                                                                                                                  |

### Videos

The following table provides a list of videos about CI/CD, sorted in reverse chronological order of publish date:

| Publish Date | Video                                                                                                                                                              |
|:-------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 2017-07-17   | [GitLab CI/CD Deep Dive](https://youtu.be/pBe4t1CD8Fc?t=195).                                                                                                      |
| 2017-03-13   | [Demo: CI/CD with GitLab in action](https://about.gitlab.com/2017/03/13/ci-cd-demo/).                                                                              |
| 2016-04-20   | [Webcast Recording and Slides: Getting started with CI in GitLab](https://about.gitlab.com/2016/04/20/webcast-recording-and-slides-introduction-to-ci-in-gitlab/). |

In addition, the following third-party videos are available:

- [Intégration continue avec GitLab (September 2016)](https://www.youtube.com/watch?v=URcMBXjIr24&t=13s).
- [GitLab CI for Minecraft Plugins (July 2016)](https://www.youtube.com/watch?v=Z4pcI9F8yf8).

### Example Projects

[`review-apps-nginx`](https://gitlab.com/gitlab-examples/review-apps-nginx/) provides an example of using Review Apps.

Other example projects are available at the [`gitlab-examples`](https://gitlab.com/gitlab-examples) group.

### Why GitLab CI/CD?

The following articles explain reasons why you might use GitLab CI/CD for your CI/CD infrastructure:

- [Why we chose GitLab CI for our CI/CD solution](https://about.gitlab.com/2016/10/17/gitlab-ci-oohlala/).
- [Building our web-app on GitLab CI](https://about.gitlab.com/2016/07/22/building-our-web-app-on-gitlab-ci/).

See also the [Why CI/CD?](https://docs.google.com/presentation/d/1OGgk2Tcxbpl7DJaIOzCX4Vqg3dlwfELC3u2jEeCBbDk) presentation.
Achilleas Pipinellis's avatar
Achilleas Pipinellis committed
188

189
190
## Breaking changes

Evan Read's avatar
Evan Read committed
191
192
193
As GitLab CI/CD has evolved, certain breaking changes have been necessary. These are:

- [CI variables renaming for GitLab 9.0](variables/README.md#gitlab-90-renaming). Read about the
194
  deprecated CI variables and what you should use for GitLab 9.0+.
Evan Read's avatar
Evan Read committed
195
196
- [New CI job permissions model](../user/project/new_ci_build_permissions_model.md).
  See what changed in GitLab 8.12 and how that affects your jobs.
197
  There's a new way to access your Git submodules and LFS objects in jobs.