Azure Pipeline Part 2 – Triggers

Azure Pipeline Part 2 – Triggers

Azure Pipeline Part 2 – Triggers

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

Today we are going to discuss different ways to trigger an Azure Pipeline. Azure Pipeline supports triggering an Azure Pipeline based on push, pull, schedule, from another pipeline or manually using UI or API.

Azure Pipeline Part 2 – Triggers


Initial setup:

Push trigger:

A push trigger specifies which branches, tags or path changes will result in Azure Pipeline trigger. Push triggers are defined using “trigger” keyword in Azure Pipeline config file. “trigger” keyword support “include” and “exclude” keywords to include or exclude an branch, tag or path from triggering your pipeline. You can also use wildcard characters with include or exclude keywords.

Note: If you specify an exclude clause without an include clause for branches, tags, or paths, it is equivalent to specifying * in the include clause.

Azure Pipeline Push Triggers Syntax:

Azure Pipeline Push Triggers Examples:

By default, any push to your Azure pipeline repository will trigger the pipeline if trigger keyword is excluded from the pipeline config file.

You can also disable your Azure Pipeline from getting triggered using “trigger: none” in your pipeline config file.

Trigger Azure Pipeline only for specific branches.

Trigger Azure Pipeline only in specific tags.

Trigger Azure Pipeline only if specific file or directory content gets changed.

Next, we will explore scheduled trigger in Azure Pipeline.

Scheduled trigger:

Scheduled triggers start your pipeline based on a schedule, such as a nightly build. Scheduled triggers are configured using “schedules” keyword in Azure Pipeline config file.

Azure Pipeline Scheduled Triggers Syntax:

Azure Pipeline Scheduled Triggers Examples:

Trigger Azure Pipeline on specific schedule.

Pipeline Triggers:

You can execute another Azure Pipeline from an Azure Pipeline using “resource” keyword.

Azure Pipeline Triggers Syntax:

Pull (PR) trigger:

A pull request trigger specifies which branches cause a pull request build to run. If you specify no pull request trigger, pull requests to any branch trigger a build. Sadly, YAML PR triggers are supported only in GitHub and Bitbucket Cloud and currently not supported for Azure Repos, hence not included an example.

Azure Pipeline Pull (PR) Trigger Syntax:

Azure Pipeline Pull (PR) Trigger Example:

Not supported for Azure Repos, only GitHub and Bitbucket is supported.

Manual trigger:

You can also manually trigger an Azure Pipeline from Azure DevOps console or using REST API.

Manual trigger using Azure DevOps console:

Azure Pipeline Part 2 – Triggers

Manual Trigger using REST API:

Clean up:

Hope you have enjoyed this article. To know more about Azure DevOps, please refer below official documentation

Leave a Reply

Close Menu