How to Use Trigger and Branch Filters in Azure Pipelines
The trigger and pr keys decide which branches start CI runs, with include/exclude lists and path filters.
Use trigger: for CI on push and pr: for validation builds. Each supports branches and paths include/exclude to scope runs.
Branch and path filters
Run CI on main and release branches, but only when source files change.
azure-pipelines.yml
trigger:
branches:
include:
- main
- releases/*
paths:
include:
- src/*
exclude:
- docs/*
pr:
branches:
include:
- mainGotchas
- For Azure Repos,
pr:triggers work in YAML; for GitHub repos, PR triggers may rely on branch policies instead. - Setting
trigger: nonedisables CI triggering entirely (useful for manual-only or template pipelines). - Path filters help monorepos, but a build with no matching paths is skipped, not failed.
Related guides
How to Use Conditions and Expressions in Azure PipelinesControl when stages, jobs, and steps run in Azure Pipelines with condition expressions - succeeded, eq, and,…
How to Create a Multi-Stage Pipeline in Azure PipelinesBuild a build-test-deploy multi-stage pipeline in Azure Pipelines with dependsOn chaining and condition so de…