1
votes

I have a single project but with two "master" branches.

  • master
  • virt/master

Each of them would have their own azure-pipeline.yml specific for their branch.

The first pipeline in master has the trigger set up as

trigger:
  batch: true
  branches:
    include:
      - refs/heads/master

The second one is in the virt/master branch.

trigger:
  batch: true
  branches:
    include:
      - refs/heads/virt/master

Here's the repository that I am experimenting on https://dev.azure.com/trajano/experiments/_git/multi-branch

The problem I am having is when I push a change to the virt/master branch both pipelines get executed

enter image description here

Am I missing something in my configuration? Or is this a bug on Azure Devops?

I also tried to exclude but to no avail.

trigger:
  batch: true
  branches:
    include:
      - refs/heads/master
    exclude:
      - refs/heads/virt/master
2
Perhaps this will clear things up for you: They should both use the same pipeline. When a pipeline is triggered, it will use the version of the file in the branch that's being built.Daniel Mann

2 Answers

1
votes

To create different pipelines for different branches. You need to rename the azure-pipelines.yml file in virt/master branch or create a new yml file with the some contents and with a different name. And create pipeline multi-branch(virt) from this new yml file.

If both pipelines are created from the yaml file with the same name azure-pipeline.yml. And the azure-pipeline.yml file exists in both of the branches. Then they are identical pipelines(even though the azure-pipeline.yml file contents might be different).

You can see from above screen. Pipeline multi-branch and multi-branch(virt) were building the same virt/master branch(using the tasks in the azure-pipeline.yml of virt/master). If you push to master branch. You will see both pipelines will be triggered to build master branch(using the tasks in the azure-pipeline.yml of master). Pipeline multi-branch and multi-branch(virt) are one pipeline

See this thread for more information.

2
votes

If you want to have separate pipelines please create separate file definition for them. I think that your configuration is fine and the issue is that you share the same file as definition.

When I moved to separate file it works as expected:

enter image description here