Commit 9daae83f authored by Evan Read's avatar Evan Read

Merge branch 'patch-49' into 'master'

Improve documentation of RegExp in CI/CD job ref patterns

See merge request gitlab-org/gitlab-ce!28139
parents d7e106b7 ec1a4032
...@@ -386,17 +386,12 @@ job: ...@@ -386,17 +386,12 @@ job:
- branches@gitlab-org/gitlab-ce - branches@gitlab-org/gitlab-ce
except: except:
- master@gitlab-org/gitlab-ce - 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`, The above example will run `job` for all branches on `gitlab-org/gitlab-ce`,
except `master` and those with names prefixed with `release/`. 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 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. default. If it doesn't have an `except` rule, it is empty.
...@@ -415,6 +410,28 @@ job: ...@@ -415,6 +410,28 @@ job:
only: ['branches', 'tags'] 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 ### Supported `only`/`except` regexp syntax
CAUTION: **Warning:** CAUTION: **Warning:**
......
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