Azure Devops - How to prevent multiple pipelines run at same time?

Viewed 5161

I've two different pipelines with 3 enabled agents. My problem is that one of my pipelines fails if has multiple builds running at same time (because tets are running into conflict), so I want to queue an build request if there is another one running for this specific pipeline.

The first thing i've tried it's use capabilities and demands to identify one agent, so always has only one agent available to this pipeline, but it doesn't work with Microsoft-hosted agents and that it's what i have. Then I thought that maybe creating 2 agent pools I can specify on my pipeline config to use one of them, but one more time I can't create multiple pools for Microsoft-hosted agents

How can I prevent multiple builds running at same time?

Thanks!

2 Answers

Finally I resolved my problem passing from Build to Build + Release.

The solution of @Fairoz not works for me because still alowing multplie builds of different branches runs at same time. What I need it's to lock an pipeline until there's no builds running. The way to do this on Azure Devops it's with Capabilities + Demands, but not works with Microsoft-hosted agents, so what I made i'ts move all my tests logic to an Release that deploys to CI and leave the build that just make an Artifact.

So the workflow it's: PR to Github > Trigger Build > Generate an artifact with my branch > Trigger release > Release code to CI and run the tests

Azure Devops allow to control how many parallel executions of one Stage can exists, so I limited to 1 the number of parallel tasks and that's it

Related