2

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?

karthik
  • 21
  • 1
  • 4
  • 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 Nov 30 '20 at 07:20

1 Answers1

4

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.

Jane Ma-MSFT
  • 4,461
  • 1
  • 6
  • 12
  • Appreciate your response, but this is not what I'm looking for. I would like to enable or disable a pipeline not to run/cancel it. Disabling the pipeline will restrict the users to run it, Users can only be able to run the pipelines when it is in enabled state. Options for enabling or disabling the pipeline will be present in pipeline settings, "Processing of new run requests" is the field – karthik Nov 30 '20 at 13:35
  • @karthik Sorry for the misunderstanding. I have updated my answer for you. – Jane Ma-MSFT Dec 01 '20 at 06:41
  • @karthik Hello there, not get your latest news. Is there any updates for this question? – Jane Ma-MSFT Dec 03 '20 at 09:00
  • For me this doesn't work. I `PUT` the entire json with the modified `queueStatus` parameter, but the pipeline is still enabled. – hey Mar 21 '22 at 00:52