78

I'm currently trying to create multiple build pipelines for my Angular app in Azure DevOps using the new YAML way. I used to create a new build pipeline for the different environments I've set up (dev, staging, prod) when I was using the "legacy" visual builder.

But since I've switched to YAML-style build definitions everytime I try to create a new pipeline I get redirected to the existing azure-pipelines.yml. As far as I can tell from the docs it is not possible to define multiple pipelines in a single .yml file either.

Is this scenario currently not supported in Azure DevOps?

riQQ
  • 9,878
  • 7
  • 49
  • 66
Thomas
  • 4,030
  • 4
  • 40
  • 79
  • 1
    YAML should support multiple documents within the same file. Just add 3 - between the documents. Like: Document 1 --- Document 2 – Cedervall Jun 04 '21 at 11:09

3 Answers3

60

@4c74356b41's answer was correct, but now you can create as many build configurations using different yaml files and also with continuous integration without creating manual builds.

On the new pipeline flow follow these steps:

1. Choose where is your code:

step1

2. Select the repository of your code (the one which has the yml file):

step2

3. On the configure pipeline, choose Existing Azure Pipelines YAML file:

step3

4. Select the branch and the path where the yaml file is, then continue: Note: If it's not shown make sure your file has .yml extension

step4

5. Finally click RUN.

Note: After creating the pipeline this way, it will have continuous integration activated, but if you still want to have manual building follow the next:

Select your build and then Triggers:

step5

And then disable continuous integration:

step6

Or even easier, just add the line trigger: none to your yaml file.

Joshua K
  • 457
  • 3
  • 12
David Noreña
  • 3,951
  • 1
  • 28
  • 43
  • 1
    what is difference between pr trigger and ci trigger? – Hari Kiran Jun 15 '20 at 23:50
  • 1
    Think of it as: CI always, for all branches, PR, only executes when you create or update a branch related to a PR. In the new Multistage-Pipelines is easier :), you configure everything from your yaml. – David Noreña Jun 15 '20 at 23:54
  • suppose I create PR from my personal branch to dev branch and have pr triggers in yaml set to dev branch, does that mean everytime I create a PR to dev branch, it will kick off a PR build? – Hari Kiran Jun 16 '20 at 00:02
  • Oh, you right, I forgot to say that you CANNOT configure PRs from YAML, you need to configure that from BRANCH POLICY, so the PR would be build from whatever branch you set the policy on. On the other hand the YAML has a configure to INCLUDE some branches on CI mode. – David Noreña Jun 16 '20 at 01:28
  • 1
    Thanks for showing where we could set different .yml file for different pipeline. Exactly what I needed! – Tommy Leong Mar 03 '22 at 09:51
  • @TommyLeong glad it worked for you ! :) – David Noreña Mar 03 '22 at 14:42
44

It is supported. azure-pipelines.yml is being auto-picked up by VSTS, you can create as many yaml files and create builds manually for those. that's the only difference.

so you need to manually create builds for different envs using different yaml files.

enter image description here

on the build steps selection pick this:

enter image description here

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • I've just added a new .yml build definition to the root of my source and merged it all the way to my master branch, but it does not show up. Also, how can I name the pipeline? – Thomas Dec 13 '18 at 17:33
  • you just need to create a new build manually, like you normally would – 4c74356b41 Dec 13 '18 at 17:44
  • 13
    Uh, so you need to use the visual builder which does not support YAML to pick the YAML file you've created manually. Well that's not confusing… Thanks though – Thomas Dec 13 '18 at 17:49
  • This is also how one can specify `.azure-pipelines.yml`, if prefers dot-name instead the default `azure-pipelines.yml` – mloskot Jan 09 '19 at 06:01
  • 21
    I've created a step by step blog on how to do this if anyone is interested https://sethreid.co.nz/using-multiple-yaml-build-definitions-azure-devops/ – sethreidnz Jan 12 '19 at 07:08
15

The process has changed. As of June 2020, the steps are:

Step 1 - From Pipelines, click New Pipeline:

enter image description here

Step 2 - After selecting your source, your repo, and the default pipeline type, rename the pipeline YAML file by clicking here:

enter image description here

Step 3 - Rename the pipeline by clicking rename/move:

enter image description here

james.garriss
  • 12,959
  • 7
  • 83
  • 96
  • This was the issue for me. Leaving the default -1.yml broke my existing pipeline, and the additional didn't run. Renaming it worked. – Gavin Thomas Dec 29 '21 at 18:47