Commit 83c7a6c5 authored by Marcel Amirault's avatar Marcel Amirault Committed by Suzanne Selhorn

Change only examples to rules

parent 84f9c5c7
...@@ -18,6 +18,7 @@ exceptions: ...@@ -18,6 +18,7 @@ exceptions:
- ARN - ARN
- ASCII - ASCII
- AWS - AWS
- CLI
- CNAME - CNAME
- CPU - CPU
- CSS - CSS
...@@ -34,9 +35,10 @@ exceptions: ...@@ -34,9 +35,10 @@ exceptions:
- HTTP - HTTP
- HTTPS - HTTPS
- IAM - IAM
- IBM
- IDE - IDE
- IRC - IRC
- IBM - ISO
- JSON - JSON
- LDAP - LDAP
- LDAPS - LDAPS
......
...@@ -3626,30 +3626,21 @@ For more information, see [Deployments Safety](../environments/deployment_safety ...@@ -3626,30 +3626,21 @@ For more information, see [Deployments Safety](../environments/deployment_safety
> [Introduced](https://gitlab.com/gitlab-org/gitlab/merge_requests/19298) in GitLab 13.2. > [Introduced](https://gitlab.com/gitlab-org/gitlab/merge_requests/19298) in GitLab 13.2.
`release` indicates that the job will create a [Release](../../user/project/releases/index.md), `release` indicates that the job creates a [Release](../../user/project/releases/index.md),
and optionally include URLs for Release assets. and optionally includes URLs for Release assets.
These methods are supported: These methods are supported:
- [`name`](#releasename)
- [`description`](#releasedescription)
- [`tag_name`](#releasetag_name) - [`tag_name`](#releasetag_name)
- [`ref`](#releaseref) - [`name`](#releasename) (optional)
- [`milestones`](#releasemilestones) - [`description`](#releasedescription) (optional)
- [`released_at`](#releasereleased_at) - [`ref`](#releaseref) (optional)
- [`milestones`](#releasemilestones) (optional)
- [`released_at`](#releasereleased_at) (optional)
The Release is created only if the job processes without error. If the Rails API The Release is created only if the job processes without error. If the Rails API
returns an error during Release creation, the `release` job fails. returns an error during Release creation, the `release` job fails.
#### Tags
A `release` job should not be run against a tag commit, or it will continually re-trigger itself. This can be specified by including:
```yaml
only:
- tags
```
#### `release-cli` Docker image #### `release-cli` Docker image
The Docker image to use for the `release-cli` must be specified, using the following directive: The Docker image to use for the `release-cli` must be specified, using the following directive:
...@@ -3674,23 +3665,25 @@ A pipeline can have multiple `release` jobs, for example: ...@@ -3674,23 +3665,25 @@ A pipeline can have multiple `release` jobs, for example:
```yaml ```yaml
ios-release: ios-release:
script: release > changelog.md script:
- echo 'iOS release job'
release: release:
tag_name: v1.0.0-ios tag_name: v1.0.0-ios
description: changelog.md description: 'iOS release v1.0.0'
android-release: android-release:
script: release > changelog.md script:
- echo 'Android release job'
release: release:
tag_name: v1.0.0-android tag_name: v1.0.0-android
description: changelog.md description: 'Android release v1.0.0'
``` ```
#### `release:tag_name` #### `release:tag_name`
The `tag_name` must be specified. It can refer to an existing Git tag or can be specified by the user. The `tag_name` must be specified. It can refer to an existing Git tag or can be specified by the user.
When the specified tag doesn't exist in repository, a new tag is created from the associated SHA of the pipeline. When the specified tag doesn't exist in the repository, a new tag is created from the associated SHA of the pipeline.
For example, when creating a Release from a Git tag: For example, when creating a Release from a Git tag:
...@@ -3699,8 +3692,6 @@ job: ...@@ -3699,8 +3692,6 @@ job:
release: release:
tag_name: $CI_COMMIT_TAG tag_name: $CI_COMMIT_TAG
description: changelog.txt description: changelog.txt
only:
- tags
``` ```
It is also possible to create any unique tag, in which case `only: tags` is not mandatory. It is also possible to create any unique tag, in which case `only: tags` is not mandatory.
...@@ -3719,17 +3710,16 @@ job: ...@@ -3719,17 +3710,16 @@ job:
#### `release:name` #### `release:name`
The Release name. This is an optional field. If omitted, it is populated with The Release name. If omitted, it is populated with the value of `release: tag_name`.
`release:tag_name`.
#### `release:description` #### `release:description`
Specifies a file containing the longer description of the Release. This is a mandatory Specifies the longer description of the Release.
field and can point to a changelog.
#### `release:ref` #### `release:ref`
When the `tag_name` does not exist, `release:ref` specifies the commit to be used instead of the pipeline `ref`. If `tag_name` doesn’t exist, the release will be created from `ref`. `ref` can be a commit SHA, another tag name, or a branch name. If the `release: tag_name` doesn’t exist yet, the release is created from `ref`.
`ref` can be a commit SHA, another tag name, or a branch name.
#### `release:milestones` #### `release:milestones`
...@@ -3737,36 +3727,64 @@ The title of each milestone the release is associated with. ...@@ -3737,36 +3727,64 @@ The title of each milestone the release is associated with.
#### `release:released_at` #### `release:released_at`
The date when the release will be or was ready. Defaults to the current time. Expected in ISO 8601 format (2019-03-15T08:00:00Z). The date and time when the release is ready. Defaults to the current date and time if not
defined. Expected in ISO 8601 format (2019-03-15T08:00:00Z).
#### Complete example for `release` #### Complete example for `release`
Combining the individual examples given above for `release`, we'd have the following code snippet: Combining the individual examples given above for `release` results in the following
code snippets. There are two options, depending on how you generate the
tags. These options cannot be used together, so choose one:
```yaml - To create a release when you push a Git tag, or when you add a Git tag
stages: in the UI by going to **Repository > Tags**:
- build
- test
- release-stg
release_job: ```yaml
stage: release release_job:
image: registry.gitlab.com/gitlab-org/release-cli:latest stage: release
only: image: registry.gitlab.com/gitlab-org/release-cli:latest
- tags rules:
script: - if: $CI_COMMIT_TAG # Run this job when a tag is created manually
- echo 'running release_job' script:
release: - echo 'running release_job'
name: 'Release $CI_COMMIT_SHA' release:
description: 'Created using the release-cli $EXTRA_DESCRIPTION' name: 'Release $CI_COMMIT_TAG'
tag_name: 'release-$CI_COMMIT_SHA' description: 'Created using the release-cli $EXTRA_DESCRIPTION' # $EXTRA_DESCRIPTION must be defined
ref: '$CI_COMMIT_SHA' tag_name: '$CI_COMMIT_TAG' # elsewhere in the pipeline.
milestones: ref: '$CI_COMMIT_TAG'
- 'm1' milestones:
- 'm2' - 'm1'
- 'm3' - 'm2'
released_at: '2020-07-15T08:00:00Z' - 'm3'
``` released_at: '2020-07-15T08:00:00Z' # Optional, will auto generate if not defined,
# or can use a variable.
```
- To create a release automatically when changes are pushed to the default branch,
using a new Git tag that is defined with variables:
```yaml
release_job:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: $CI_COMMIT_TAG
when: never # Do not run this job when a tag is created manually
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when the default branch changes
script:
- echo 'running release_job'
release:
name: 'Release $CI_COMMIT_SHA'
description: 'Created using the release-cli $EXTRA_DESCRIPTION' # $EXTRA_DESCRIPTION and the tag_name
tag_name: 'v${MAJOR}.${MINOR}.${REVISION}' # variables must be defined elsewhere
ref: '$CI_COMMIT_SHA' # in the pipeline.
milestones:
- 'm1'
- 'm2'
- 'm3'
released_at: '2020-07-15T08:00:00Z' # Optional, will auto generate if not defined,
# or can use a variable.
```
#### `releaser-cli` command line #### `releaser-cli` command line
...@@ -3774,10 +3792,10 @@ The entries under the `:release` node are transformed into a `bash` command line ...@@ -3774,10 +3792,10 @@ The entries under the `:release` node are transformed into a `bash` command line
to the Docker container, which contains the [release-cli](https://gitlab.com/gitlab-org/release-cli). to the Docker container, which contains the [release-cli](https://gitlab.com/gitlab-org/release-cli).
You can also call the `release-cli` directly from a `script` entry. You can also call the `release-cli` directly from a `script` entry.
The YAML described above would be transferred into a command line like this: The YAML described above would be translated into a CLI command like this:
```shell ```shell
release-cli create --name "Release $CI_COMMIT_SHA" --description "Created using the release-cli $EXTRA_DESCRIPTION" --tag-name "release-$CI_COMMIT_SHA" --ref "$CI_COMMIT_SHA" --released-at "2020-07-15T08:00:00Z" --milestone "m1" --milestone "m2" --milestone "m3" release-cli create --name "Release $CI_COMMIT_SHA" --description "Created using the release-cli $EXTRA_DESCRIPTION" --tag-name "v${MAJOR}.${MINOR}.${REVISION}" --ref "$CI_COMMIT_SHA" --released-at "2020-07-15T08:00:00Z" --milestone "m1" --milestone "m2" --milestone "m3"
``` ```
### `pages` ### `pages`
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment