Reputation: 1414
I'm having trouble with setting up a build where commits with only changes to markdown files do not trigger the build.
On the build, I have continuous integration enabled with "include" branch filters.
To exclude changes to markdown files I setup a single "exclude" path filters to **/*.md
, which from my understanding of file matching patterns should recursively match all files that end in .md
. However, when I push just a change to a markdown file, the build is still triggered.
I considered adding an "include" path filter with /
, but the builds are still being triggered without it.
How do I specify specify to not build when only a certain file type was changed?
Upvotes: 13
Views: 13560
Reputation: 40779
The newest update from 08/09/2021 made possible to use wild cards in path filter.
Wild cards can be used when specifying inclusion and exclusion branches for CI or PR triggers in a pipeline YAML file. However, they cannot be used when specifying path filters. For instance, you cannot include all paths that match src/app//myapp*. This has been pointed out as an inconvenience by several customers. This update fills this gap. Now, you can use wild card characters (, *, or ?) when specifying path filters.
So now it should be possible to ave triggers as follows:
trigger:
branches:
include:
- master
paths:
include:
- src/
exclude:
- '/**/*.md'
Upvotes: 12
Reputation: 4445
As of now, wild cards are not supported for these file path filters.
You're going to be forced into a different convention to bypass the trigger for these files.
Putting .md
files in an explicit structure (ex: /docs) that you can exclude with the "pattern" given in the examples you linked exclude: docs/
.
Given the following director structure:
(repo)
\src
|\d1
| \md
|
\d2
\md
**
as recursive inclusion prefixWith the following trigger specification to attempt an include on a directory using double wildcard syntax:
trigger:
branches:
include:
- master
paths:
include:
- /src/**/md/
When a change is made inside the /md
directory, then the trigger is not invoked.
**
as recursive exclusion prefixWith the following trigger specification to attempt to exclude a directory using double wildcard syntax:
trigger:
branches:
include:
- master
paths:
include:
- src/
exclude:
- src/**/md/
When a change is made to files in either .../md
directory, the trigger is invoked.
With the following trigger specification to attempt an exclude on a fully specified directory path (no wildcard syntax)
trigger:
branches:
include:
- master
paths:
include:
- src/
exclude:
- src/d1/md/
When changes are made to a file inside src/d1/md
, then the trigger is not invoked. When changes are made to files inside src/d1
or any other part of the structure, then the trigger is invoked.
This same behavior holds true for your specific desire to try and call out a group of files using *.md
.
Given each directory has a [variant]_README.md
file in it, the following is true:
*
wildcard as file nameWith the following trigger specification to attempt exclusion of any .md
file under src/d1/md/
from causing invocation, when changes are made to src/d1/md/f1_README.md
, then the trigger is invoked.
trigger:
branches:
include:
- master
paths:
include:
- src/
exclude:
- src/d1/md/*.md
*
as file name prefix wildcardWith the following trigger specification to attempt to exclude any file ending in README.md
under src/d1/md
from causing invocation, when changes are made to src/d1/md/f1_README.md
, then the trigger is invoked.
trigger:
branches:
include:
- master
paths:
include:
- src/
exclude:
- src/d1/md/*README.md
**
and *
as recursive any file extension exclusionWith the following trigger specification to attempt exclusion of any .md
file anywhere in the repository from causing invocation, when changes are made to src/d1/md/f1_README.md
or any other .md
file, then the trigger is invoked.
trigger:
branches:
include:
- master
paths:
include:
- src/
exclude:
- /**/*.md
With the following trigger specification to attempt to exclude any .md
file in the repository from causing an invocation, when changes are made to src/d1/md/f1_README.md
or any other .md
file, the trigger is invoked.
trigger:
branches:
include:
- master
paths:
include:
- src/
exclude:
- /*.md
CI is NOT triggered
when changes are made to src/d1/md/f1_README.md
trigger:
branches:
include:
- master
paths:
include:
- src/
exclude:
- src/d1/md/f1_README.md
Upvotes: 19