Pipeline trigger rules
Develop and implement pipeline trigger rules
Triggers decide when a pipeline runs. The defaults depend on the repository provider and on settings outside the YAML file.
Omitted triggers are conditionally on
With Disable implied YAML CI trigger off and no pipeline UI override, an omitted
triggerenables CI for pushes to all branches. The organization or project setting is off by default.
For GitHub and Bitbucket Cloud, omitting pr enables YAML PR builds for pull
requests to any branch when no UI override applies. Azure Repos Git does not use
YAML pr triggers; configure branch-policy build validation instead.
Disable CI explicitly with trigger: none. For a GitHub or Bitbucket Cloud
YAML pipeline, disable YAML PR builds with pr: none:
trigger: none # no CI trigger
pr: none # no PR triggerKeep two controls separate:
- Disable implied YAML CI trigger is an organization/project control. It
suppresses implicit CI only when
triggeris omitted; it does not defeat an explicittrigger: none. - Override the YAML trigger from here is a per-pipeline UI control that can
supersede explicit YAML
triggerand supportedprsettings.
Filtering
trigger:
branches:
include: [ main, releases/* ]
exclude: [ releases/legacy/* ]
paths:
include: [ src/* ]
exclude: [ docs/* ]
batch: true- Exclude beats include. A branch matching both is excluded.
- Path filters stop documentation-only commits from burning agent time.
batch: truecollects commits arriving during an in-flight run and runs them together when it finishes, instead of queueing one run per push.
Scheduled triggers
schedules:
- cron: "0 2 * * *"
displayName: Nightly
branches:
include: [ main ]
always: falsealways: false — the default — runs only when source code or pipeline settings
have changed since the last successful scheduled run. Set it to true for jobs
that must run despite unchanged repository state, such as a nightly dependency
scan whose useful input is an external advisory feed.
Cron here is UTC, which is the usual source of "why did it run an hour early" after a daylight-saving change.
UI-defined schedules take precedence over YAML schedules. If both exist, only the UI schedules run until they are removed and a push refreshes YAML schedule evaluation.
Primary sources
- https://learn.microsoft.com/en-us/azure/devops/pipelines/build/triggers
- https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/trigger
- https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/pr
- https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/github
- https://learn.microsoft.com/en-us/azure/devops/pipelines/process/scheduled-triggers
- https://learn.microsoft.com/en-us/azure/devops/pipelines/troubleshooting/troubleshoot-triggers