Azure Devops disable concurrent runs on the same pipeline

I think you can use adding demands to the pool on the agent job of pipelines, so that it will run with one same agent because of the same specified condition.

First, add one Capability in the agent.

enter image description here

And then, in your YAML, add demands to the pool.

pool:
  name: {agent pool name}
  demands: Limit -equals DisAbleParallel 

The format of it is demands:{CapabilityName} -equals {CapabilityValue}.

While you specified the agent demands, the pipeline will just run with this agent. While A is running, the second one will not run at same time because the previous is running, the agent is being using. So that, the second one will run until previous ends.


Looks like you can do this by using the trigger options in the yaml file:

trigger:  
    batch: true

Do note that this value is false by default (so when left empty), but it might only be when a trigger has been defined?

Docs here: https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#triggers