Bulk update Azure Release Pipelines tasks

If you’re attempting to update a sprawling amount of release definitions, clicking through each definition using the visual designer can be a real chore. That’s why Task Groups really come in handy…But if you’re already stuck with a bunch of definitions that don’t utilize task groups, you’ll probably want to turn to the REST API using PowerShell.

Start by getting a list of all release definitions:

GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions?api-version=5.0

Loop through each definition using the ID from the response above:

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

Using the response above, navigate to the task field of the object:

$GetDefinitionResponse.environments.deployPhases.workflowTasks

Loop through each task and set desired properties on the object. Use the catalog of tasks to figure out required arguments for each task.

$Task.version = '2.*'

Convert the definition object to JSON to be used in PUT below:

$GetDefinitionResponse | ConvertTo-Json -Depth 100

Use updated definition object to update the definition via PUT:

PUT https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions?api-version=5.0

Here is an example script I used to update all release definition’s WindowsMachineFileCopy task from version 1 to version 2:

Leave a Reply

Your email address will not be published. Required fields are marked *