Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
986c7720
Commit
986c7720
authored
Dec 02, 2020
by
Suzanne Selhorn
Committed by
Marcel Amirault
Dec 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Docs: Edited ci.yml conceptual topic
parent
cfdb739b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
41 deletions
+60
-41
doc/ci/yaml/gitlab_ci_yaml.md
doc/ci/yaml/gitlab_ci_yaml.md
+60
-41
No files found.
doc/ci/yaml/gitlab_ci_yaml.md
View file @
986c7720
...
@@ -8,62 +8,81 @@ type: reference
...
@@ -8,62 +8,81 @@ type: reference
# The .gitlab-ci.yml file
# The .gitlab-ci.yml file
<!-- markdownlint-enable MD044 -->
<!-- markdownlint-enable MD044 -->
To use GitLab CI/CD, you need an application codebase hosted in a
To use GitLab CI/CD, you need:
Git repository, and for your build, test, and deployment
scripts to be specified in a file called
[
`.gitlab-ci.yml`
](
README.md
)
,
-
Application code hosted in a Git repository.
located in the root path of your repository.
-
A file called
[
`.gitlab-ci.yml`
](
README.md
)
in the root of your repository, which
contains the CI/CD configuration.
In this file, you can define the scripts you want to run, define include and
cache dependencies, choose commands you want to run in sequence
In the
`.gitlab-ci.yml`
file, you can define:
and those you want to run in parallel, define where you want to
deploy your app, and specify whether you want to run the scripts automatically
-
The scripts you want to run.
or trigger any of them manually. After you're familiar with
-
Other configuration files and templates you want to include.
GitLab CI/CD you can add more advanced steps into the configuration file.
-
Dependencies and caches.
-
The commands you want to run in sequence and those you want to run in parallel.
To add scripts to that file, you need to organize them in a
-
The location to deploy your application to.
sequence that suits your application and are in accordance with
-
Whether you want to run the scripts automatically or trigger any of them manually.
the tests you wish to perform. To visualize the process, imagine
that all the scripts you add to the configuration file are the
The scripts are grouped into
**jobs**
, and jobs run as part of a larger
same as the commands you run on a terminal on your computer.
**pipeline**
. You can group multiple independent jobs into
**stages**
that run in a defined order.
After you've added your
`.gitlab-ci.yml`
configuration file to your
You should organize your jobs in a sequence that suits your application and is in accordance with
repository, GitLab detects it and run your scripts with the
the tests you wish to perform. To
[
visualize
](
visualization.md
)
the process, imagine
tool called
[
GitLab Runner
](
https://docs.gitlab.com/runner/
)
, which
the scripts you add to jobs are the same as CLI commands you run on your computer.
works similarly to your terminal.
When you add a
`.gitlab-ci.yml`
file to your
The scripts are grouped into
**jobs**
, and together they compose
repository, GitLab detects it and an application called
[
GitLab Runner
](
https://docs.gitlab.com/runner/
)
a
**pipeline**
. A minimalist example of
`.gitlab-ci.yml`
file
runs the scripts defined in the jobs.
could contain:
A
`.gitlab-ci.yml`
file might contain:
```
yaml
```
yaml
before_script
:
stages
:
-
apt-get install rubygems ruby-dev -y
-
build
-
test
build-code-job
:
stage
:
build
script
:
-
echo "Check the ruby version, then build some Ruby project files:"
-
ruby -v
-
rake
run-test
:
test-code-job1
:
stage
:
test
script
:
script
:
-
ruby --version
-
echo "If the files are built successfully, test some files with one command:"
-
rake test1
test-code-job2
:
stage
:
test
script
:
-
echo "If the files are built successfully, test other files with a different command:"
-
rake test2
```
```
The
`before_script`
attribute would install the dependencies
In this example, the
`build-code-job`
job in the
`build`
stage runs first. It outputs
for your app before running anything, and a
**job**
called
the Ruby version the job is using, then runs
`rake`
to build project files.
`run-test`
would print the Ruby version of the current system.
If this job completes successfully, the two
`test-code-job`
jobs in the
`test`
stage start
Both of them compose a
**pipeline**
triggered at every push
in parallel and run tests on the files.
to any branch of the repository.
The full pipeline in the example is composed of three jobs, grouped into two stages,
`build`
and
`test`
. The pipeline runs every time changes are pushed to any
branch in the project.
GitLab CI/CD not only executes the jobs you've
GitLab CI/CD not only executes the jobs but also shows you what's happening during execution,
set but also shows you what's happening during execution, as you
just as you would see in your terminal:
would see in your terminal:
![
job running
](
img/job_running.png
)
![
job running
](
img/job_running.png
)
You create the strategy for your app and GitLab runs the pipeline
You create the strategy for your app and GitLab runs the pipeline
for you
according to what you've defined. Your pipeline status is also
according to what you've defined. Your pipeline status is also
displayed by GitLab:
displayed by GitLab:
![
pipeline status
](
img/pipeline_status.png
)
![
pipeline status
](
img/pipeline_status.png
)
At the end, if anything goes wrong, you can easily
If anything goes wrong, you can
[
roll back
](
../environments/index.md#retrying-and-rolling-back
)
all
the changes:
[
roll back
](
../environments/index.md#retrying-and-rolling-back
)
the changes:
![
rollback button
](
img/rollback.png
)
![
rollback button
](
img/rollback.png
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment