2
votes

I am trying to build a YAML release pipeline in Azure DevOps for that I have created multiple branches to keep environment-specific files

first image

I created 4 pipelines for release as well:

second image

Problem: Whenever I am making any changes in any branch, all the branch pipeline starts running. If I run an individual pipeline it works fine.

# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- acc

pool:
  name: 'Agent'

steps:

- task: Kubernetes@1
  displayName: 'Deploy on  K8s Cluster'
  inputs:
    connectionType: 'Azure Resource Manager'
    azureSubscriptionEndpoint: 'vs-aks-sc'
    azureResourceGroup: 'azwe-rg-01'
    kubernetesCluster: 'azwe-aks-01'
    command: 'apply'
    arguments: '-f $(System.DefaultWorkingDirectory)/kubernetes/acc.yaml'

third

deploy

2
can you share your YAML files? probably the issue is there.Shayki Abramczyk
What you mean "If i run individual pipeline it work fine."? Manually run each pipeline?Leo Liu-MSFT
Yes if i manually run each pipeline it work fine, howver if i change anything in branches present in azure repo all branch run the same pipelineSatyam Pandey
@SatyamPandey, Thanks for your reply. Need to confirm one more things, you said all branch run the same pipeline instead of "all the branch pipeline starts running", that mean those four branch run the same pipeline rather than their respective pipelines, am I right?Leo Liu-MSFT
Yes all the branches starts running the same pipeline,Satyam Pandey

2 Answers

1
votes

You should check the CI trigger setting of the pipeline to only allow it to trigger on your wanted branches

Change CI Trigger

2
votes

Problem: Whenever I am making any changes in any branch, all the branch pipeline starts running.

If you just want to run the corresponding pipeline of the branch you modified, you need to make sure set the pipeline with the YAML file in the corresponding branch and set the correct branch trigger.

For example, for the Acc branch:

We need create a YAML file under the branch Feature/TestSample-acc with the branch trigger in the YAML file:

trigger: 
  branches:
    include:
      - Feature/TestSample-acc

enter image description here

Then create a pipeline with existing Azure pipeline YAML file:

New Pipeline-> Azure Repos Git(YAML)-> Select your repository-> Select existing Azure pipeline YAML file:

enter image description here

Now, this pipeline only triggered by the modification on the branch Feature/TestSample-acc:

enter image description here

You could set the same this for other branches, like

trigger: 
      branches:
        include:
          - Feature/TestSample-dev

Besides, if you do not want to control the trigger by the YAML file, you could override it by the UI trigger settings:

enter image description here

This option is disable by default, so that we could control the trigger in the YAML file directly.

If you enable it, you just need to add the Branch filters for just one branch:

enter image description here

If I am not understand your question correctly, please let me know for free that what you want to achieve.