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
665ce5e1
Commit
665ce5e1
authored
Jun 15, 2021
by
Marcel Amirault
Committed by
Amy Qualls
Jun 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update CI/CD examples to use rules
parent
7e5275f9
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
55 additions
and
56 deletions
+55
-56
doc/ci/docker/using_kaniko.md
doc/ci/docker/using_kaniko.md
+2
-2
doc/ci/environments/index.md
doc/ci/environments/index.md
+8
-8
doc/ci/migration/jenkins.md
doc/ci/migration/jenkins.md
+5
-3
doc/ci/parent_child_pipelines.md
doc/ci/parent_child_pipelines.md
+1
-1
doc/ci/pipelines/schedules.md
doc/ci/pipelines/schedules.md
+8
-13
doc/ci/triggers/README.md
doc/ci/triggers/README.md
+6
-6
doc/ci/variables/where_variables_can_be_used.md
doc/ci/variables/where_variables_can_be_used.md
+3
-4
doc/ci/yaml/README.md
doc/ci/yaml/README.md
+20
-17
doc/ci/yaml/includes.md
doc/ci/yaml/includes.md
+2
-2
No files found.
doc/ci/docker/using_kaniko.md
View file @
665ce5e1
...
@@ -99,8 +99,8 @@ build:
...
@@ -99,8 +99,8 @@ build:
KANIKOCFG="${KANIKOCFG} }"
KANIKOCFG="${KANIKOCFG} }"
echo "${KANIKOCFG}" > /kaniko/.docker/config.json
echo "${KANIKOCFG}" > /kaniko/.docker/config.json
-
/kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile $KANIKOPROXYBUILDARGS --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
-
/kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile $KANIKOPROXYBUILDARGS --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
only
:
rules
:
-
tags
-
if
:
$CI_COMMIT_TAG
```
```
## Using a registry with a custom certificate
## Using a registry with a custom certificate
...
...
doc/ci/environments/index.md
View file @
665ce5e1
...
@@ -99,10 +99,10 @@ deploy_review:
...
@@ -99,10 +99,10 @@ deploy_review:
environment
:
environment
:
name
:
review/$CI_COMMIT_REF_NAME
name
:
review/$CI_COMMIT_REF_NAME
url
:
https://$CI_ENVIRONMENT_SLUG.example.com
url
:
https://$CI_ENVIRONMENT_SLUG.example.com
only
:
rules
:
-
branches
-
if
:
$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
except
:
when
:
never
-
master
-
if
:
$CI_COMMIT_BRANCH
```
```
In this example:
In this example:
...
@@ -158,8 +158,8 @@ deploy_prod:
...
@@ -158,8 +158,8 @@ deploy_prod:
name
:
production
name
:
production
url
:
https://example.com
url
:
https://example.com
when
:
manual
when
:
manual
only
:
rules
:
-
master
-
if
:
$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
```
```
The
`when: manual`
action:
The
`when: manual`
action:
...
@@ -200,8 +200,8 @@ deploy:
...
@@ -200,8 +200,8 @@ deploy:
url
:
https://example.com
url
:
https://example.com
kubernetes
:
kubernetes
:
namespace
:
production
namespace
:
production
only
:
rules
:
-
master
-
if
:
$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
```
```
When you use the GitLab Kubernetes integration to deploy to a Kubernetes cluster,
When you use the GitLab Kubernetes integration to deploy to a Kubernetes cluster,
...
...
doc/ci/migration/jenkins.md
View file @
665ce5e1
...
@@ -349,12 +349,14 @@ variable entry.
...
@@ -349,12 +349,14 @@ variable entry.
GitLab does support a
[
`when` keyword
](
../yaml/README.md#when
)
which is used to indicate when a job should be
GitLab does support a
[
`when` keyword
](
../yaml/README.md#when
)
which is used to indicate when a job should be
run in case of (or despite) failure, but most of the logic for controlling pipelines can be found in
run in case of (or despite) failure, but most of the logic for controlling pipelines can be found in
our very powerful
[
`only/except` rules system
](
../yaml/README.md#only--except
)
our very powerful
[
`rules` system
](
../yaml/README.md#rules
)
:
(see also our
[
advanced syntax
](
../yaml/README.md#only--except
)
):
```
yaml
```
yaml
my_job
:
my_job
:
only
:
[
branches
]
script
:
-
echo
rules
:
-
if
:
$CI_COMMIT_BRANCH
```
```
## Additional resources
## Additional resources
...
...
doc/ci/parent_child_pipelines.md
View file @
665ce5e1
...
@@ -38,7 +38,7 @@ set of concurrently running child pipelines, but within the same project:
...
@@ -38,7 +38,7 @@ set of concurrently running child pipelines, but within the same project:
Child pipelines work well with other GitLab CI/CD features:
Child pipelines work well with other GitLab CI/CD features:
-
Use
[
`
only: changes`
](
yaml/README.md#onlychanges--except
changes
)
to trigger pipelines only when
-
Use
[
`
rules: changes`
](
yaml/README.md#rules
changes
)
to trigger pipelines only when
certain files change. This is useful for monorepos, for example.
certain files change. This is useful for monorepos, for example.
-
Since the parent pipeline in
`.gitlab-ci.yml`
and the child pipeline run as normal
-
Since the parent pipeline in
`.gitlab-ci.yml`
and the child pipeline run as normal
pipelines, they can have their own behaviors and sequencing in relation to triggers.
pipelines, they can have their own behaviors and sequencing in relation to triggers.
...
...
doc/ci/pipelines/schedules.md
View file @
665ce5e1
...
@@ -8,9 +8,6 @@ type: reference, howto
...
@@ -8,9 +8,6 @@ type: reference, howto
# Pipeline schedules **(FREE)**
# Pipeline schedules **(FREE)**
> - Introduced in GitLab 9.1 as [Trigger Schedule](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/10533).
> - [Renamed to Pipeline Schedule](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/10853) in GitLab 9.2.
Pipelines are normally run based on certain conditions being met. For example, when a branch is pushed to repository.
Pipelines are normally run based on certain conditions being met. For example, when a branch is pushed to repository.
Pipeline schedules can be used to also run
[
pipelines
](
index.md
)
at specific intervals. For example:
Pipeline schedules can be used to also run
[
pipelines
](
index.md
)
at specific intervals. For example:
...
@@ -54,31 +51,29 @@ is installed on.
...
@@ -54,31 +51,29 @@ is installed on.
### Using variables
### Using variables
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/12328) in GitLab 9.4.
You can pass any number of arbitrary variables. They are available in
You can pass any number of arbitrary variables. They are available in
GitLab CI/CD so that they can be used in your
[
`.gitlab-ci.yml` file
](
../../ci/yaml/README.md
)
.
GitLab CI/CD so that they can be used in your
[
`.gitlab-ci.yml` file
](
../../ci/yaml/README.md
)
.
![
Scheduled pipeline variables
](
img/pipeline_schedule_variables.png
)
![
Scheduled pipeline variables
](
img/pipeline_schedule_variables.png
)
### Using
only and except
### Using
`rules`
To configure a job to be executed only when the pipeline has been
To configure a job to be executed only when the pipeline has been
scheduled (or the opposite), use
scheduled, use the
[
`rules`
](
../yaml/README.md#rules
)
keyword.
[
only and except
](
../yaml/README.md#only--except
)
configuration keywords.
In the example below
`make world`
runs in scheduled pipelines, and
`make build`
runs in pipelines that are not scheduled:
In this example,
`make world`
runs in scheduled pipelines, and
`make build`
runs in branch and tag pipelines:
```
yaml
```
yaml
job:on-schedule:
job:on-schedule:
only
:
rules
:
-
schedules
-
if
:
$CI_PIPELINE_SOURCE == "schedule"
script
:
script
:
-
make world
-
make world
job
:
job
:
except
:
rules
:
-
schedules
-
if
:
$CI_PIPELINE_SOURCE = "push"
script
:
script
:
-
make build
-
make build
```
```
...
...
doc/ci/triggers/README.md
View file @
665ce5e1
...
@@ -57,8 +57,8 @@ trigger_pipeline:
...
@@ -57,8 +57,8 @@ trigger_pipeline:
stage
:
deploy
stage
:
deploy
script
:
script
:
-
curl --request POST --form "token=$CI_JOB_TOKEN" --form ref=main "https://gitlab.example.com/api/v4/projects/9/trigger/pipeline"
-
curl --request POST --form "token=$CI_JOB_TOKEN" --form ref=main "https://gitlab.example.com/api/v4/projects/9/trigger/pipeline"
only
:
rules
:
-
tags
-
if
:
$CI_COMMIT_TAG
```
```
Pipelines triggered that way also expose a special variable:
Pipelines triggered that way also expose a special variable:
...
@@ -83,8 +83,8 @@ build_submodule:
...
@@ -83,8 +83,8 @@ build_submodule:
-
apt update && apt install -y unzip
-
apt update && apt install -y unzip
-
curl --location --output artifacts.zip "https://gitlab.example.com/api/v4/projects/1/jobs/artifacts/main/download?job=test&job_token=$CI_JOB_TOKEN"
-
curl --location --output artifacts.zip "https://gitlab.example.com/api/v4/projects/1/jobs/artifacts/main/download?job=test&job_token=$CI_JOB_TOKEN"
-
unzip artifacts.zip
-
unzip artifacts.zip
only
:
rules
:
-
tags
-
if
:
$CI_COMMIT_TAG
```
```
This allows you to use that for multi-project pipelines and download artifacts
This allows you to use that for multi-project pipelines and download artifacts
...
@@ -163,8 +163,8 @@ trigger_pipeline:
...
@@ -163,8 +163,8 @@ trigger_pipeline:
stage
:
deploy
stage
:
deploy
script
:
script
:
-
'
curl
--request
POST
--form
token=TOKEN
--form
ref=main
"https://gitlab.example.com/api/v4/projects/9/trigger/pipeline"'
-
'
curl
--request
POST
--form
token=TOKEN
--form
ref=main
"https://gitlab.example.com/api/v4/projects/9/trigger/pipeline"'
only
:
rules
:
-
tags
-
if
:
$CI_COMMIT_TAG
```
```
This means that whenever a new tag is pushed on project A, the job runs and the
This means that whenever a new tag is pushed on project A, the job runs and the
...
...
doc/ci/variables/where_variables_can_be_used.md
View file @
665ce5e1
...
@@ -193,7 +193,6 @@ my-job:
...
@@ -193,7 +193,6 @@ my-job:
name
:
review/$CI_JOB_STAGE/deploy
name
:
review/$CI_JOB_STAGE/deploy
script
:
script
:
-
'
deploy
staging'
-
'
deploy
staging'
only
:
rules
:
variables
:
-
if
:
$STAGING_SECRET == 'something'
-
$STAGING_SECRET == 'something'
```
```
doc/ci/yaml/README.md
View file @
665ce5e1
...
@@ -991,8 +991,8 @@ but you can use as many as eleven. The following example has two levels of inher
...
@@ -991,8 +991,8 @@ but you can use as many as eleven. The following example has two levels of inher
```
yaml
```
yaml
.tests
:
.tests
:
only
:
rules
:
-
pushes
-
if
:
$CI_PIPELINE_SOURCE == "push"
.rspec
:
.rspec
:
extends
:
.tests
extends
:
.tests
...
@@ -1028,9 +1028,9 @@ levels. For example:
...
@@ -1028,9 +1028,9 @@ levels. For example:
variables
:
variables
:
URL
:
"
http://my-url.internal"
URL
:
"
http://my-url.internal"
IMPORTANT_VAR
:
"
the
details"
IMPORTANT_VAR
:
"
the
details"
only
:
rules
:
-
main
-
if
:
$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
-
stable
-
if
:
$CI_COMMIT_BRANCH == "stable"
tags
:
tags
:
-
production
-
production
script
:
script
:
...
@@ -1061,9 +1061,9 @@ rspec:
...
@@ -1061,9 +1061,9 @@ rspec:
URL
:
"
http://docker-url.internal"
URL
:
"
http://docker-url.internal"
IMPORTANT_VAR
:
"
the
details"
IMPORTANT_VAR
:
"
the
details"
GITLAB
:
"
is-awesome"
GITLAB
:
"
is-awesome"
only
:
rules
:
-
main
-
if
:
$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
-
stable
-
if
:
$CI_COMMIT_BRANCH == "stable"
tags
:
tags
:
-
docker
-
docker
image
:
alpine
image
:
alpine
...
@@ -2333,8 +2333,8 @@ To protect a manual job:
...
@@ -2333,8 +2333,8 @@ To protect a manual job:
name
:
production
name
:
production
url
:
https://example.com
url
:
https://example.com
when
:
manual
when
:
manual
only
:
rules
:
-
main
-
if
:
$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
```
```
1.
In the
[
protected environments settings
](
../environments/protected_environments.md#protecting-environments
)
,
1.
In the
[
protected environments settings
](
../environments/protected_environments.md#protecting-environments
)
,
...
@@ -3281,8 +3281,8 @@ Create artifacts only for tags (`default-job` doesn't create artifacts):
...
@@ -3281,8 +3281,8 @@ Create artifacts only for tags (`default-job` doesn't create artifacts):
default-job
:
default-job
:
script
:
script
:
-
mvn test -U
-
mvn test -U
except
:
rules
:
-
tags
-
if
:
$CI_COMMIT_BRANCH
release-job
:
release-job
:
script
:
script
:
...
@@ -3290,8 +3290,8 @@ release-job:
...
@@ -3290,8 +3290,8 @@ release-job:
artifacts
:
artifacts
:
paths
:
paths
:
-
target/*.war
-
target/*.war
only
:
rules
:
-
tags
-
if
:
$CI_COMMIT_TAG
```
```
You can use wildcards for directories too. For example, if you want to get all the files inside the directories that end with
`xyz`
:
You can use wildcards for directories too. For example, if you want to get all the files inside the directories that end with
`xyz`
:
...
@@ -4370,7 +4370,10 @@ job:
...
@@ -4370,7 +4370,10 @@ job:
description
:
'
Release
description'
description
:
'
Release
description'
```
```
It is also possible to create any unique tag, in which case
`only: tags`
is not mandatory.
It is also possible for the release job to automatically create a new unique tag. In that case,
do not use
[
`rules`
](
#rules
)
or
[
`only`
](
#only--except
)
to configure the job to
only run for tags.
A semantic versioning example:
A semantic versioning example:
```
yaml
```
yaml
...
@@ -4626,8 +4629,8 @@ pages:
...
@@ -4626,8 +4629,8 @@ pages:
artifacts
:
artifacts
:
paths
:
paths
:
-
public
-
public
only
:
rules
:
-
main
-
if
:
$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
```
```
View the
[
GitLab Pages user documentation
](
../../user/project/pages/index.md
)
.
View the
[
GitLab Pages user documentation
](
../../user/project/pages/index.md
)
.
...
...
doc/ci/yaml/includes.md
View file @
665ce5e1
...
@@ -111,8 +111,8 @@ production:
...
@@ -111,8 +111,8 @@ production:
environment
:
environment
:
name
:
production
name
:
production
url
:
https://$CI_PROJECT_PATH_SLUG.$KUBE_INGRESS_BASE_DOMAIN
url
:
https://$CI_PROJECT_PATH_SLUG.$KUBE_INGRESS_BASE_DOMAIN
only
:
rules
:
-
main
-
if
:
$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
```
```
Content of
`.gitlab-ci.yml`
:
Content of
`.gitlab-ci.yml`
:
...
...
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