Reputation: 3687
In template pipelines you can't place any trigger statement such as trigger: none
as specified in Microsoft's docs to disable ci trigger, so I wonder how do you prevent these pipelines from being executed every time you update them or any other yaml file in the same branch?
Upvotes: 61
Views: 80086
Reputation: 13648
The pipeline yaml definition now supports disabling all triggers with
trigger: none
Upvotes: 113
Reputation: 19225
There are no less than three spots in Azure DevOps that may be used to disable automatic build. Which one do you use to disable the irritating automatic builds that occur? Not sure
Firstly, Pipeline triggers as described here. I had to disable this to stop GitHub kicking off an automatic pipeline for PR's https://stackoverflow.com/a/74133429/1690193
Confusingly this isn't in the immediate pipeline hamburger menu, it's under "Edit" then hamburger/triggers. As far as I can tell it doesn't change any source code but it does request a commit message. So much for YAML being the one true definition of deployment
Secondly, In Project/Settings there's a switch for "Disable implied YAML CI trigger".
Thridly, trigger: none
in the YAML itself. This being the only actual area where your config is captured in Git
Upvotes: 1
Reputation: 1389
First you need to go to your Pipelines dashboard, then select the pipeline that you want to disable CI for it
then Click on Edit
You will be redirected to the pipeline yaml file, from there you will click on the vertical ellipsis ⋮
=> Triggers
and here you go, you can disable CI for your pipeline that easily
Save it, and you are done.
Upvotes: 17
Reputation: 25543
Other answers are fine.
Here is another approach I found. I have a yaml based build pipeline. I did not want to touch the yaml just for disabling the trigger. So I disabled the pipeline as follows.
Upvotes: 6
Reputation: 3687
So in the end in a template pipeline you can't state something like trigger: none
(to set only manual triggering) and you cannot specify stages or jobs, only steps are allowed (so you can't define any condition to prevent pipeline execution on the job or on the stage).
You have an option to disable the CI trigger by going in the triggers section for the template pipeline and select the following:
I don't like much this option because it means having pipeline configuration that is not captured in the yaml pipeline definition but I found no other way to disable the template pipeline from being triggered every time something (including the pipeline itself) is updated in its branch.
Upvotes: 43
Reputation: 40849
If you want to update your template without affecting pipelines which uses this template make a change on separate branch and merge it to master (or whatever you use) once you are sure that you have what you want.
The same applies if you use template from different repo:
# Repo: Contoso/WindowsProduct
# File: azure-pipelines.yml
resources:
repositories:
- repository: templates
type: github
name: Contoso/BuildTemplates
ref: refs/tags/v1.0 # optional ref to pin to
jobs:
- template: common.yml@templates # Template reference
parameters:
vmImage: 'vs2017-win2016'
By default you use template from your main branch, but you can point to any branch you want. Thus you can also test that your changes on limited pipelines as you need to point directly to a branch where you modified your template.
Let's say you have that branching:
master
|_ feature/add-extra-step
And you make a change in template but on feature/add-extra-step
by adding additional step.
Now hen you trigger pipeline which uses that template:
master
- your additional step in template won't be runfeature/add-extra-step
- your additional step will be runI made a change in template on feature/extra-step
branch:
And this is change is not avialable when I run pipeline (even the same pipeline) on master:
If you for instance don't want to trigger ci build making changes on template, pleace commit those changes with phrase [skip ci]
in th git message. Check here for more details.
Upvotes: 2