Azure DevOps Pipelines - prevent unwanted triggers

October 16, 2023

If you are a user of YAML pipelines in Azure DevOps , you might have encountered this annoying issue with the pipeline trigger. Let's discuss about this issue in detail and how a recently released feature will prevent this issue

Issue:

In YAML pipeline trigger section is used to specify when a pipeline should be executed

Consider the following snippet - In this scenario, the pipeline will be triggered for any changes to the main branch or branches that match the pattern releases/*


trigger:
- main
- releases/*

what if we omit the trigger section completely from a pipeline?.

you might expect the pipeline will not be triggered automatically however the exact opposite scenario will happen.

i.e. the pipeline will get triggered for changes to any branch This is a disastrous situation to be in, especially if the same pipeline is used to build as well as deploy.

A code from dev branch can get deployed to production in such cases. unfortunately, the default trigger is "all" and not "none"

Prevent unintended pipeline runs:

Recently a new pipeline setting has been introduced at both the project level and organisation level which can change the behaviour

If enabled, pipelines will not be triggered when the trigger section is missing. An explicit trigger specification will always be required.

disable pipeline trigger

To enable the setting at the Organization level, go to "Organization Settings" --> "Settings" --> under the Triggers section enable "Disable implied YAML CI trigger"

disable trigger organization

To enable the setting at the project level, go to "Project Settings" --> "Settings" --> under the Triggers section enable "Disable implied YAML CI trigger"

disable trigger project

Summary:

This issue has been causing a lot of confusion due to unintended builds and deployments.

Many thanks to Azure DevOps Team for rolling out the settings. A simple setting can now help avoid lot of confusion.

Thanks for reading, Goodbye until next week!


Profile picture

Written by Thillai Madhavan who lives and works in India. Stay updated by following him on LinkedIn.

All the information on this website - OrganicDevops.com - is published in good faith and for general information purposes only. OrganicDevops.com does not make any warranties about the completeness, reliability and accuracy of this information. Any action you take upon the information you find on this website (OrganicDevops.com), is strictly at your own risk. OrganicDevops.com will not be liable for any losses and/or damages in connection with the use of our website. From our website, you can visit other websites by following hyperlinks to such external sites. While we strive to provide only quality links to useful and ethical websites, we have no control over the content and nature of these sites. These links to other websites do not imply a recommendation for all the content found on these sites. Site owners and content may change without notice and may occur before we have the opportunity to remove a link that may have gone 'bad'. Please be also aware that when you leave our website, other sites may have different privacy policies and terms which are beyond our control. Please be sure to check the Privacy Policies of these sites as well as their "Terms of Service" before engaging in any business or uploading any information. By using our website, you hereby consent to our disclaimer and agree to its terms. Should we update, amend or make any changes to this document, those changes will be prominently posted here
© 2024, OrganicDevOps