Pipeline trigger rules
Develop and implement pipeline trigger rules
Triggers decide when a pipeline runs. The single most examinable fact is what happens when you write nothing at all.
The defaults are ON
If you do not explicitly configure triggers, all branches have CI triggers enabled, and PR triggers are enabled for pull requests to any branch.
This surprises people who assume an unconfigured pipeline is inert. To switch them off you must say so explicitly:
trigger: none # no CI trigger
pr: none # no PR triggerTwo overrides can defeat what the YAML says: the Disable implied CI trigger setting, and UI settings override YAML trigger. If a pipeline is not firing as the file suggests it should, those are the first places to look.
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 — means the scheduled run is skipped when
nothing has changed since the last successful scheduled run. Set it to true
for jobs that must run regardless, such as a nightly dependency scan.
Cron here is UTC, which is the usual source of "why did it run an hour early" after a daylight-saving change.
Primary sources