How to Trigger on Branches, Tags, and Paths in Azure Pipelines
The trigger block includes and excludes branches, tags, and paths so a run only starts for commits you care about.
Set trigger with branches, tags, and paths, each supporting include and exclude lists. A push runs the pipeline only when it matches the include filters and not the excludes.
Steps
- Add a
triggerblock withbranches.include. - Add
paths.include/paths.excludeto scope by directory. - Add
tags.includeto also run for matching tags.
Pipeline
azure-pipelines.yml
trigger:
branches:
include:
- main
- releases/*
tags:
include:
- v*
paths:
include:
- services/api/**
exclude:
- docs/**
steps:
- script: cd services/api && npm ci && npm testGotchas
- Branch names in filters are bare (
main), notrefs/heads/main. pathsfilters only apply to branch triggers, not to tag triggers.- Setting
trigger: nonedisables CI runs so the pipeline only runs manually or on a schedule.
Related guides
How to Trigger a Pipeline on Pull Requests in Azure PipelinesValidate pull requests in Azure Pipelines with a pr trigger that runs on PRs into target branches, the basis…
How to Conditionally Run a Stage or Job in Azure PipelinesRun an Azure Pipelines stage or job only when a condition holds using the condition key with expressions like…