Lesson393 words

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 trigger enables 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:

yaml
trigger: none # no CI trigger pr: none # no PR trigger

Keep two controls separate:

  • Disable implied YAML CI trigger is an organization/project control. It suppresses implicit CI only when trigger is omitted; it does not defeat an explicit trigger: none.
  • Override the YAML trigger from here is a per-pipeline UI control that can supersede explicit YAML trigger and supported pr settings.

Filtering

yaml
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: true collects commits arriving during an in-flight run and runs them together when it finishes, instead of queueing one run per push.

Scheduled triggers

yaml
schedules: - cron: "0 2 * * *" displayName: Nightly branches: include: [ main ] always: false

always: 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

Ready to study Designing and Implementing Microsoft DevOps Solutions (AZ-400)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free