You can add a gate of Invoke REST API: GET
to call below Deployments - List rest api and check if there are any releases in deployment. See below steps:
https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/deployments?operationStatus=queued,queuedForAgent,phaseInProgress&api-version=6.1-preview.2
1, Add a Invoke Rest Api Gate
Go to Pre-deployment conditions --> Enable Gate-->Add a Invoke Rest Api Gate-->Click Manage to create a service connection. See below screenshot.
2, Create a service connection shown in above screenshot.
When you Click Manage in above screenshot. You will be forward to service connections page. Click new service connection and select Generic type of service connection:
3, Go back to the Invoke Rest Api Gate. Select the service connection just created: See below
- Method:
Get
- URL suffix and parameters:
/_apis/release/deployments?operationStatus=queued,queuedForAgent,phaseInProgress&api-version=6.1-preview.2
- Success criteria:
eq(root['value'][0], '')
Above Invoke rest api gate will call the deployments list
rest api to filter these releases that are inProgress or queued of deployment using operationStatus
filter(ie. operationStatus=queued,queuedForAgent,phaseInProgress
). If the there is any deloyment is inProgress or queued the Success criteria: eq(root['value'][0], '')
will failed.
If you using self-hosted agents and Environments. You can check the Exclusive lock on Environments and Agent pools.