1
votes

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://docs.microsoft.com/en-us/rest/api/azure/devops/pipelines/pipelines?view=azure-devops-rest-6.0 https://docs.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?

1
Please check whether my answer can help you. I understand the enable/disable as run/cancel. If there is any misunderstanding, feel free to let me know.Jane Ma-MSFT

1 Answers

1
votes

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.