Azure DevOps

Good to know Azure DevOps Build Triggers

Azure DevOps | CI | CD | Pipeline

Arun Kumar Singh
3 min readMar 13, 2022

--

Photo by MIOPS Trigger on Unsplash

Trigger in CI/CD Pipelines are important to create an effective CI/CD process. In Azure DevOps, you can configure pipelines for manual or automated triggers. The triggers will execute the pipeline whenever there is a commit or pull happens. You can schedule the trigger for a specific time as well. The details on Azure DevOps triggers can be found in the documentation itself but I am trying to cover the most important ones which can make your life easy.

Please note all YAML pipelines which you create in Azure DevOps are configured by default with a CI trigger on all branches. Azure DevOps allows you multiple ways to control them. I am listing a few of them below.

Git Branches:-

To control triggers, if a change is pushed to master or to any releases branch you can define it in the YAML file by using trigger.

You can define what branches should be included for triggers and options of include and exclude gives more granular control. Apart from this, the pathoption can let you ignore the change in a specific directory.

# trigger specified
trigger:
branches:
include:
- main
- hotfix/*
- releases/*
exclude:
- features/*
paths:
include:
- notes
exclude:
- documents/README.md
# Please note Paths are always specified relative to the root of the repository

Git Branches Tags:-

Another good option is using branch tags. This is very helpful in case you are putting tags with respect to releases.

trigger:
branches:
include:
- refs/tags/{tagname}
exclude:
- refs/tags/{othertagname}

There is an option of directly specifying tags to include or exclude:

# specific tag
trigger:
tags:
include:
- v1.*
exclude:
- v0.*

In certain scenarios when automated triggers are enabled and devs don't want to build for commits then specific commit messages are available in Azure DevOps to avoid the build.

--

--