diff options
author | Raphael Das Gupta <raphael.das.gupta@hsr.ch> | 2019-05-29 00:53:49 +0300 |
---|---|---|
committer | Evan Read <eread@gitlab.com> | 2019-05-29 00:53:49 +0300 |
commit | ec1a4032d3cc64293d65485b8ffe84462c1959a9 (patch) | |
tree | 67cc3dd3878a19b90390c3bbbc330224d0dca36a /doc/ci/yaml/README.md | |
parent | d7e106b7b98563394f548cf1da6b59e1644fd5b8 (diff) |
Improve documentation of RegExp in CI/CD job ref patterns
as requested by https://gitlab.com/gitlab-org/gitlab-ce/issues/30477#note_29060568 in #30477
Diffstat (limited to 'doc/ci/yaml/README.md')
-rw-r--r-- | doc/ci/yaml/README.md | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md index 8667eacd3d5..18c85618b1b 100644 --- a/doc/ci/yaml/README.md +++ b/doc/ci/yaml/README.md @@ -386,17 +386,12 @@ job: - branches@gitlab-org/gitlab-ce except: - master@gitlab-org/gitlab-ce - - release/.*@gitlab-org/gitlab-ce + - /^release/.*$/@gitlab-org/gitlab-ce ``` The above example will run `job` for all branches on `gitlab-org/gitlab-ce`, except `master` and those with names prefixed with `release/`. -NOTE: **Note:** -Because `@` is used to denote the beginning of a ref's repository path, -matching a ref name containing the `@` character in a regular expression -requires the use of the hex character code match `\x40`. - If a job does not have an `only` rule, `only: ['branches', 'tags']` is set by default. If it doesn't have an `except` rule, it is empty. @@ -415,6 +410,28 @@ job: only: ['branches', 'tags'] ``` +#### Regular expressions + +Because `@` is used to denote the beginning of a ref's repository path, +matching a ref name containing the `@` character in a regular expression +requires the use of the hex character code match `\x40`. + +Only the tag or branch name can be matched by a regular expression. +The repository path, if given, is always matched literally. + +If a regular expression shall be used to match the tag or branch name, +the entire ref name part of the pattern has to be a regular expression, +and must be surrounded by `/`. +(With regular expression flags appended after the closing `/`.) +So `issue-/.*/` won't work to match all tag names or branch names +that begin with `issue-`. + +TIP: **Tip** +Use anchors `^` and `$` to avoid the regular expression +matching only a substring of the tag name or branch name. +For example, `/^issue-.*$/` is equivalent to `/^issue-/`, +while just `/issue/` would also match a branch called `severe-issues`. + ### Supported `only`/`except` regexp syntax CAUTION: **Warning:** |