How to enable batching in azure pipeline for specific branches

Viewed 1633

While creating a pipeline, I want to enable batching for specific branches and not so for other branches, is there a way of doing so in microsoft azure pipelines ?

If I enable batch:true it runs for all branches and if I remove it, it doesn't work for any branches

I have it like

trigger:
    batch: true
    branches:
        include:
            - master
            - A*
            - B*
            - C*
            - D*
            - TEST
            - Develop

I don't want batching only for master branch but want batching for other branches, can this be achieved without creating seperate pipeline yml just to enable batch:true in the same pipeline ?

1 Answers

In the Azure DevOps Service, the yaml build just trigger and batch for current branch.

For example:

If we create YAML build in the master branch, it will create azure-pipelines.yml file in the master branch. Edit the YAML build definition, such as:

trigger:
    batch: true
    branches:
        include:
            - master
            - TEST

Switch to TEST branch and edit the azure-pipelines.yml file, such as:

trigger:
    batch: true
    branches:
        include:
            - master

Then push code in the TEST branch, it will not trigger the build and queue a new build.

I want to enable batching for specific branches and not so for other branches,

As a work around, we could switch the branch, edit the YAML file and enable batching for specific branch. This will not affect other branches.

Note: Since the file is different in the different branches, the file azure-pipelines.yml will conflict when we create PR

Update

Thanks for @Hiteshdua1 sharing.

The solution is create different yaml build definitions, then we could enable batching for specific branches and not so for other branches.

Related