Azure DevOps : how to disable CI trigger on a YAML template pipeline?

63k views Asked by At

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?

5

There are 5 answers

2
whatever On BEST ANSWER

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:

enter image description here

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.

7
Krzysztof Madej On

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:

  • trigger goes from master - your additional step in template won't be run
  • trigger goes from feature/add-extra-step - your additional step will be run

I made a change in template on feature/extra-step branch:

enter image description here

And this is change is not avialable when I run pipeline (even the same pipeline) on master:

enter image description here

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.

1
Mifeet On

The pipeline yaml definition now supports disabling all trigers with

trigger: none

Reference

0
VivekDev On

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.

  1. Pick your pipeline and double click to edit it.

Pick your pipeline and edit it

  1. Go to the settings.

Go to settings

  1. Now you should see an option to disable. Note here we are disabling the pipeline, not just disabling trigger to the pipeline.

Disable pipeline

0
Holy semicolon On

First you need to go to your Pipelines dashboard, then select the pipeline that you want to disable CI for it Pipelines Dashboard Image

then Click on Edit

Edit Pipeline Image

You will be redirected to the pipeline yaml file, from there you will click on the vertical ellipsis => Triggers

enter image description here

and here you go, you can disable CI for your pipeline that easily

enter image description here

Save it, and you are done.