0
votes

I have a Azure Devops pipeline (yml) with a stage that deploys an application to an environment and then runs a bunch of tests against it. This pipeline is triggered when a PR is created. We sometimes have multiple runs of the same pipelines happening at once resulting in two deployments to the same environment happening at the same time.

Is it possible to configure the pipeline in such a way that the deploy stage can only be executed one at a time?


Simple example of what I'm trying to do:

Pipeline (yml) with stages: 1) Build -> 2) Deploy/Test -> 3) Release

Run 1: Build: complete -> Deploy/Test In progress -> Release waiting for stage 2

Run 2: Build: complete -> Deploy/Test waiting for Run 1 stage 2

1

1 Answers

0
votes

If you use YAML then make you release in deployment job where you use environment with enabled exclusive lock. However, this has some drawback:

enter image description here

On developer community you can find a feature request for better handling this. And there is one workaround which involved calling REST API. But, as someone already mentioned:

Workarounds involving polling end up with race conditions where two queued builds can both end up starting.

So there is no ideal solution, but if you can please upvote above mentioned request.