Commit 193e579c authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

doc(workflow): extend (skip ci) feature

parent 5951c403
Loading
Loading
Loading
Loading
Loading
+48 −0
Original line number Diff line number Diff line
@@ -263,6 +263,36 @@ variables:

Those variables are used internally thoughout all _to be continuous_ templates.

## Extended `[skip ci]` feature

GitLab skips triggering the CI/CD pipeline when `[skip ci]` or `[ci skip]` is present in the Git commit message.

This feature can be handy, but in some situations you would like to skip the CI/CD pipeline only under certain
circumstances. Example: when creating a release with a Git commit containing only _bumpversion_ changes (setting 
the new released version in configuration and/or documentation files). This commit will also be pushed as a tag. 
You might want to prevent the commit from being processed twice (one from the origin branch **and** one from the tag pipeline).

For this, all the recent versions of _to be continuous_ templates implement an extended `[skip ci]` feature.
It is now possible to skip **selectively** the CI/CD pipeline if your Git commit message contains a part of the following format:

```
[ci skip on <comma separated words>]
or:
[skip ci on <comma separated words>]
```

Supported words are:

| Words   | Description                |
| ------- | -------------------------- |
| `tag`   | skipped on tag pipelines |
| `mr`    | skipped on Merge Request pipelines |
| `mr`    | skipped on branch pipelines |
| `default` | skipped on the default project branch |
| `prod`  | skipped on the [production branch](#production-and-integration-branches) |
| `integ` | skipped on the [integration branch](#production-and-integration-branches) |
| `dev`   | skipped on any development branch (other than production or integration) |

## Merge Request workflow

One thing that has to be chosen with GitLab CI/CD is the [Merge Request workflow strategy](https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines).
@@ -276,6 +306,22 @@ workflow:
    # prevent branch pipeline when an MR is open (prefer MR pipeline)
    - if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
      when: never
    # the 7 next rules implement the extended [skip ci] feature
    - if: '$CI_COMMIT_MESSAGE =~ "/\[(ci skip|skip ci) on ([^],]*,)*tag(,[^],]*)*\]/" && $CI_COMMIT_TAG'
      when: never
    - if: '$CI_COMMIT_MESSAGE =~ "/\[(ci skip|skip ci) on ([^],]*,)*branch(,[^],]*)*\]/" && $CI_COMMIT_BRANCH'
      when: never
    - if: '$CI_COMMIT_MESSAGE =~ "/\[(ci skip|skip ci) on ([^],]*,)*mr(,[^],]*)*\]/" && $CI_MERGE_REQUEST_ID'
      when: never
    - if: '$CI_COMMIT_MESSAGE =~ "/\[(ci skip|skip ci) on ([^],]*,)*default(,[^],]*)*\]/" && $CI_COMMIT_REF_NAME =~ $CI_DEFAULT_BRANCH'
      when: never
    - if: '$CI_COMMIT_MESSAGE =~ "/\[(ci skip|skip ci) on ([^],]*,)*prod(,[^],]*)*\]/" && $CI_COMMIT_REF_NAME =~ $PROD_REF'
      when: never
    - if: '$CI_COMMIT_MESSAGE =~ "/\[(ci skip|skip ci) on ([^],]*,)*integ(,[^],]*)*\]/" && $CI_COMMIT_REF_NAME =~ $INTEG_REF'
      when: never
    - if: '$CI_COMMIT_MESSAGE =~ "/\[(ci skip|skip ci) on ([^],]*,)*dev(,[^],]*)*\]/" && $CI_COMMIT_REF_NAME !~ $PROD_REF && $CI_COMMIT_REF_NAME !~ $INTEG_REF'
      when: never
    # default: execute
    - when: always
```

@@ -287,6 +333,8 @@ workflow:
    # prevent Merge Request pipeline
    - if: $CI_MERGE_REQUEST_ID
      when: never
    # /!\ you MAY keep the 7 rules implementing the extended [skip ci] feature
    # >> here <<
    - when: always
```