Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi branch Pipeline in Azure Devops

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

like image 489
Satyam Pandey Avatar asked Oct 21 '25 00:10

Satyam Pandey


2 Answers

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.

like image 135
Leo Liu-MSFT Avatar answered Oct 22 '25 14:10

Leo Liu-MSFT


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

Change CI Trigger

like image 44
lylam Avatar answered Oct 22 '25 13:10

lylam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!