4
votes

Working with Azure devops, and piplines yaml files. There is a trigger on the develop branch. However, when I am saving changes to the yaml file, it triggers a new build.

This happens cause the change to the yaml file is a new commit, captured by the trigger.

So my question is, how can I exclude changes to the yaml file, from triggering a new build?

1

1 Answers

4
votes

You can specify file paths to include or exclude. Note that the wildcard syntax is different between branches/tags and file paths.

# specific path build
trigger:
  branches:
    include:
    - master
    - releases/*
  paths:
    include:
    - docs/*
    exclude:
    - docs/README.md

Source: Build Azure Repos Git or TFS Git repositories - CI triggers - Paths

EDIT April 2021:

Wild cards are not supported with path filters.

Taken from that same source now:

You can specify file paths to include or exclude.

# specific path build
trigger:
 branches:
   include:
   - master
   - releases/*
 paths:
   include:
   - docs
   exclude:
   - docs/README.md

When you specify paths, you must explicitly specify branches to trigger on. You can't trigger a pipeline with only a path filter; you must also have a branch filter, and the changed files that match the path filter must be from a branch that matches the branch filter.

Tips:

  • Wild cards are not supported with path filters.
  • Paths are always specified relative to the root of the repository.
  • If you don't set path filters, then the root folder of the repo is implicitly included by default.
  • If you exclude a path, you cannot also include it unless you qualify it to a deeper folder. For example if you exclude /tools then you could include /tools/trigger-runs-on-these
  • The order of path filters doesn't matter.
  • Paths in Git are case-sensitive. Be sure to use the same case as the real folders.
  • You cannot use variables in paths, as variables are evaluated at runtime (after the trigger has fired).