Commit d0a0d3d3 authored by Evan Read's avatar Evan Read

Merge branch 'only-changes-docs-update' into 'master'

Add docs to `only:changes/except:changes` that discuss using regex in certain scenarios

See merge request gitlab-org/gitlab-ce!26831
parents 74ace2a4 792e76a8
...@@ -501,7 +501,7 @@ Learn more about [variables expressions](../variables/README.md#variables-expres ...@@ -501,7 +501,7 @@ Learn more about [variables expressions](../variables/README.md#variables-expres
#### `only:changes`/`except:changes` #### `only:changes`/`except:changes`
Using the `changes` keyword with `only` or `except`, makes it possible to define if Using the `changes` keyword with `only` or `except` makes it possible to define if
a job should be created based on files modified by a git push event. a job should be created based on files modified by a git push event.
For example: For example:
...@@ -518,14 +518,38 @@ docker build: ...@@ -518,14 +518,38 @@ docker build:
``` ```
In the scenario above, when pushing multiple commits to GitLab to an existing In the scenario above, when pushing multiple commits to GitLab to an existing
branch, GitLab creates and triggers `docker build` job, provided that one of the branch, GitLab creates and triggers the `docker build` job, provided that one of the
commits contains changes to either: commits contains changes to any of the following:
- The `Dockerfile` file. - The `Dockerfile` file.
- Any of the files inside `docker/scripts/` directory. - Any of the files inside `docker/scripts/` directory.
- Any of the files and subdirectories inside the `dockerfiles` directory. - Any of the files and subdirectories inside the `dockerfiles` directory.
- Any of the files with `rb`, `py`, `sh` extensions inside the `more_scripts` directory. - Any of the files with `rb`, `py`, `sh` extensions inside the `more_scripts` directory.
You can also use glob patterns to match multiple files in either the root directory of the repo, or in _any_ directory within the repo. For example:
```yaml
test:
script: npm run test
only:
changes:
- "*.json"
- "**/*.sql"
```
NOTE: **Note:**
In the example above, the expressions are wrapped double quotes because they are glob patterns. GitLab will fail to parse `.gitlab-ci.yml` files with unwrapped glob patterns.
The following example will skip the CI job if a change is detected in any file in the root directory of the repo with a `.md` extension:
```yaml
build:
script: npm run build
except:
changes:
- "*.md"
```
CAUTION: **Warning:** CAUTION: **Warning:**
There are some caveats when using this feature with new branches and tags. See There are some caveats when using this feature with new branches and tags. See
the section below. the section below.
......
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