2

Is it possible for a pipeline to have multiple triggers in one YAML file that executes different jobs per trigger?

In our pipeline, we pack each project in the solution and push it as a nuget package in our own azure devops artifacts and want to do the packing and pushing depending on the project. Saw that it is possible to specify the branch and path in the trigger, but you can only have one trigger according to this. But he only indicated it in the question, and the documentation doesn't explicitly state it.

Right now my option is to just configure different pipelines with yaml files per project but I want to ask here to confirm if this is possible or not.

  • 1
    You can add multiple triggers. You can use conditionals on tasks, jobs, stages and environments to only run in specific cases. https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#triggers – jessehouwing Oct 04 '19 at 11:10
  • 1
    And docs on conditions: https://learn.microsoft.com/en-us/azure/devops/pipelines/process/conditions?tabs=yaml&view=azure-devops – jessehouwing Oct 04 '19 at 11:12
  • alright, thanks! I would take a read. – Michael Angelo Go Oct 04 '19 at 12:03

2 Answers2

1

Agree with Jessehouwing You can add multiple triggers. You can use conditionals on tasks, jobs, stages and environments to only run in specific cases.

https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#triggers

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/conditions?tabs=yaml&view=azure-devops

DixitArora-MSFT
  • 1,768
  • 1
  • 5
  • 8
1

Thanks for the input, studied the docs but it's not possible to achieve what I wanted with just the built in tasks for azure devops. I had to make a script that does it and assign true of false values to the conditionals.

The exact answer I was looking for was in this post

  • Hi, very appreciate you shared this solution to us. You can [accept the answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) thus other SO users will be able to see whether the solution works. – Mengdi Liang Oct 12 '19 at 05:55