Edit

Specify events that trigger pipelines

Azure DevOps Services | Azure DevOps Server | Azure DevOps Server 2022

A pipeline trigger tells a pipeline when to run. You can configure a trigger to run a pipeline based on a schedule or in response to an event, such as the creation of a pull request. Azure Pipelines supports the following types of triggers:

  • Continuous integration triggers (CI triggers) run a pipeline when you push code to a branch.
  • Pull request triggers (PR triggers) run a pipeline when you raise a PR or push code to the source branch of an open PR. GitHub repositories support comment triggers that run a pipeline when you add comments on an open pull request.
  • Scheduled triggers run a pipeline on a predefined schedule.
  • Pipeline completion triggers run a pipeline when another pipeline completes.

This article provides an overview of YAML pipeline triggers and classic build pipeline triggers. Classic release pipelines have similar versions of the triggers described in the previous list. For more information, see Classic release pipeline triggers.

CI triggers

CI triggers run a pipeline when a push is made to a branch that meets the criteria defined by the trigger. Use the trigger keyword to configure a CI trigger. For example, to run a pipeline when a push is made to the main branch, specify the following trigger.

trigger:
- main

If you don't explicitly configure your pipeline, all branches have CI triggers enabled by default, unless Disable implied CI trigger is set or UI settings override YAML trigger.

If you don't explicitly configure your pipeline, all branches have CI triggers enabled by default, unless Disable implied CI trigger is set or UI settings override YAML trigger.

Note

Disable implied CI trigger is only available in Azure DevOps Server 2022.2 and higher. In Azure DevOps Server 2022 and 2022.1, CI triggers are enabled by default if not explicitly configured.

To disable CI triggers in your pipeline, use the following syntax.

trigger: none

YAML pipelines support CI triggers for the following repository types. For specific information about using CI triggers with a specific repository type, see the following articles.

For information on the full YAML trigger syntax and options available for CI triggers, see trigger definition.

Important

Paths in Git are case-sensitive, including CI and PR trigger path filters.

PR triggers

Pull request (PR) triggers cause a pipeline to run whenever you open a pull request, or when you push changes to the source branch of a pull request. Use the pr keyword to configure a PR trigger. For example, to run a pipeline when a PR is raised to the main branch, specify the following trigger.

pr:
- main

If you don't explicitly configure PR triggers in your pipeline, they're enabled by default, unless UI settings override YAML trigger. Pull requests to any branch trigger a pipeline run. To disable PR triggers in your pipeline, use the following syntax.

pr: none

YAML PR triggers are supported for GitHub and Bitbucket Cloud. For more information about using PR triggers with these types of repositories, see PR triggers in GitHub and PR triggers in Bitbucket Cloud. For information on the full YAML PR trigger syntax, see pr definition.

Azure Repos Git uses branch policies to implement PR triggers. For more information, see PR triggers in Azure Repos Git.

Comment triggers

Comment triggers configure a pipeline to run when contributors make a pull request comment containing a pull request command like /azp run. Comment triggers are supported only for GitHub repositories. For more information, see GitHub repository comment triggers.

Scheduled triggers

Scheduled triggers run a pipeline on a predefined schedule. All repository types that support YAML pipelines support scheduled triggers in YAML pipelines. These repository types include Azure Repos Git, GitHub, GitHub Enterprise Server, and Bitbucket Cloud.

To define a scheduled trigger in YAML, use the schedules keyword and define your schedule by using cron syntax. The following example configures a schedule that runs every day at midnight.

# YAML file in the main branch
schedules:
- cron: '0 0 * * *'
  displayName: Daily midnight build
  branches:
    include:
    - main

For more information and examples, see Scheduled triggers, schedules definition, and schedules.cron definition.

Pipeline completion triggers

Pipeline triggers in YAML pipelines and build completion triggers in classic build pipelines allow you to trigger one pipeline upon the completion of another.

Set up a pipeline resource trigger in your pipeline to start a pipeline run when the source pipeline finishes a run.

resources:
  pipelines:
  - pipeline: sourcePipelineResource # Label for this pipeline resource; used when referring to it elsewhere in the pipeline.
    source: source-pipeline # The name of the pipeline referenced by this pipeline resource.
    project: FabrikamProject # Required only if the source pipeline is in another project
    trigger: true # Run this pipeline when any run of source-pipeline completes

You can add multiple pipeline resources in your pipeline. You can configure the trigger to run when any version of the source pipeline finishes, or limit it to certain branches.

For more information and examples, see Pipeline completion triggers.

For the full syntax and trigger options, see resources.pipelines.pipeline definition.

Branch consideration for triggers in YAML pipelines

YAML pipelines can have different versions of the pipeline in different branches, which can affect which version of the pipeline's triggers are evaluated and which version of the pipeline should run.

Trigger type Pipeline YAML version
CI triggers (trigger) The version of the pipeline in the pushed branch is used.
PR triggers (pr) The version of the pipeline in the source branch for the pull request is used.
GitHub pull request comment triggers The version of the pipeline in the source branch for the pull request is used.
Scheduled triggers See Branch considerations for scheduled triggers.
Pipeline completion triggers See Branch considerations for pipeline completion triggers.

Classic release pipelines

Continuous deployment triggers help you start classic releases after a classic build or YAML pipeline completes.

Scheduled release triggers allow you to run a release pipeline according to a schedule.

Pull request release triggers are used to deploy a pull request directly using classic releases.

Stage triggers in classic release are used to configure how each stage in a classic release is triggered.