Single pipeline with multiple stages with multiple branches in Azure DevOps yml pipelines

Copper Contributor

Problem: I have a source code project and a repo with three branches as Master, Dev, Test. Apart from that I have also another project with a repo consists of pipeline “yml” templates like:


/jobs/Test-job.yml. …. With respective steps in it….

Note: job templates are included into respective stages

Now, I have a single pipeline.yml file with all included templates in the source code repo for all 3 branches Master, Dev, Test as follows
Pipeline.yml file

- repository: templates
type: Git
name: pipeline-templates/templates

- ‘*’

- template: stages/build-stage.yml@templates
#condition: this stage should run for all three branches

- template: stages/dev-stage.yml@templates
#condition: this stage should run for “dev” branch only

- template: stages/test-stage.yml@templates
#condition: this stage should run for “test” branch only


Question: How can I achieve this by using conditions in stages with templates???
Could someone provide some inputs, ideas and help regarding this issue!!! That would be great!!!!

0 Replies