Reputation: 91
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!
Upvotes: 7
Views: 10270
Reputation: 91
Finally I resolved my problem passing from Build to Build + Release.
The solution of @Fairoz did not work for me because it is still allowing multiple builds of different branches to run at same time. What I need is to lock a pipeline until there are no builds running. The way to do this on Azure DevOps its with Capabilities + Demands, but doesn't work with Microsoft-hosted agents, so what I did was move all my tests logic to an Release that deploys to CI and leave the build that just makes an Artifact.
So the workflow is: PR to GitHub > Trigger Build > Generate an artifact with my branch > Trigger release > Release code to CI and run the tests
Azure DevOps is allowed 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
Upvotes: 2
Reputation: 878
You can just enable the "Batch changes while a build is in progress" option to execute one pipeline at a time.
There's a similar question here: "Build after the previous execution has succeeded" in Azure Devops
Upvotes: 1