Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude file types in CI triggers on Azure Devops Pipelines Builds

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?

like image 281
Adam Avatar asked Apr 17 '19 16:04

Adam


People also ask

What are the two categories of triggers in Azure DevOps?

Continuous deployment triggers help you start classic releases after a classic build or YAML pipeline completes. Scheduled release triggers allow you to run a release pipeline according to a schedule.


2 Answers

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/.

Illustration:

Given:

(repo)
\src
   |\d1
   |   \md
   |
    \d2
       \md

The following does not trigger on changes to either /md directory.

trigger:
  branches:
    include:
      - master
  paths:
    include:
      - /src/**/md/

The following always triggers on changes under src/, even for files in both .../md directories.

trigger:
  branches:
    include:
      - master
  paths:
    include:
      - src/
    exclude:
      - src/**/md/

The following triggers on changes under src/, src/d1/, src/d2, .../d2/md but not for any changes under src/d1/md/.

trigger:
  branches:
    include:
      - master
  paths:
    include:
      - src/
    exclude:
      - src/d1/md/

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:

CI is triggered when changes are made to src/d1/md/f1_README.md

trigger:
  branches:
    include:
      - master
  paths:
    include:
      - src/
    exclude:
      - src/d1/md/*.md

CI is triggered when changes are made to src/d1/md/f1_README.md

trigger:
  branches:
    include:
      - master
  paths:
    include:
      - src/
    exclude:
      - src/d1/md/*README.md

CI is triggered when changes are made to src/d1/md/f1_README.md or any other .md file.

trigger:
  branches:
    include:
      - master
  paths:
    include:
      - src/
    exclude:
      - /**/*.md

CI is triggered when changes are made to src/d1/md/f1_README.md or any other .md file.

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
like image 131
Josh Gust Avatar answered Nov 15 '22 11:11

Josh Gust


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
like image 37
Krzysztof Madej Avatar answered Nov 15 '22 11:11

Krzysztof Madej