Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we enable/disable a Azure DevOps Pipeline using Azure Devops rest api or CLI commands

I'm trying to enable/disable multiple pipelines based on a condition, would like to create a pipeline that takes the parameter from the user and updates all the other pipelines.

I've found these below documents from Microsoft
https://learn.microsoft.com/en-us/rest/api/azure/devops/pipelines/pipelines?view=azure-devops-rest-6.0 https://learn.microsoft.com/en-us/cli/azure/ext/azure-devops/pipelines?view=azure-cli-latest

but I'm not able to find anything for enabling/disabling a pipeline, is there any way of doing this in any other ways?

like image 204
karthik Avatar asked Mar 19 '26 17:03

karthik


1 Answers

I'm not able to find anything for enabling/disabling a pipeline, is there any way of doing this in any other ways?

You can use the REST API Definitions - Update to enable or disable pipelines.

PUT https://dev.azure.com/{organization}/{project}/_apis/build/definitions/{definitionId}?api-version=6.0

For its request body, you need to get the definition of the build using the GET REST API first:

GET https://dev.azure.com/{organization}/{project}/_apis/build/definitions/{definitionId}?api-version=6.0

Use the response body of GET REST API as the request body of PUT REST API. And then modify the value of queueStatus according to your requirements.

If you want to enable the pipeline, set the value of queueStatus to enabled; If you want to disable the pipeline, set the value of queueStatus to disabled.

like image 154
Jane Ma-MSFT Avatar answered Mar 22 '26 12:03

Jane Ma-MSFT