1
votes

Is there a method to change approvers in Azure DevOps (release side) in bulk? Perhaps some CLI command?

I need to change approvers for many stages/environments within a release pipeline. I do not want to click through the GUI to do this. Is there any other option?

2
Not so related but you should define group\team as approvers then it will be easier to update approvers by just adding/removing people from the defined groups.Thomas

2 Answers

1
votes

You can do it with Azure DevOps Rest API.

There is api Approvals - Update:

PATCH https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/approvals/{approvalId}?api-version=5.0
1
votes

If you are a fan of Powershell I wrote a module for solving problems just like this one. It's called AzurePipelinesPS it's open source so it is consistently being updated.

Simply run Install-Module -Name AzurePipelinesPS -Force in an administrative PowerShell session to download the module. From there you can use the New-APSession command to store your session information for later use. Check out the project documentation for how to create and save session information.

Once you have a session you can run the following commands to locate all the pending approvals for a team project to Powershell's out grid view command, select the approvals you would like to use and click okay. The approvals will be saved to the $approvals variable and then passed to the Update-APApproval command. The Update-APApproval command will set the status to 'approved'. It also supports all of the available approval statuses for rejecting approvals as well.

$approvals = Get-APApprovalList -Session 'yourSessionName' | Out-GridView -PassThru Update-APApproval -Session 'yourSessionName' -ApprovalId $approvals.Id -Status 'Approved'

Edit: After re-reading your question, I believe you are not looking to bulk approve releases but rather bulk edit the release definitions themselves. You can still use AzurePipelinesPS to do so but what you are trying to accomplish is a little more complex than the initial question. However I will do my best to explain it.

First you can loop through the definitions you would like with the Get-APReleaseDefinitionList. This will identify the release ids you will need to use Get-APReleaseDefinition -ReleaseId $yourIds. Next you can loop through the definition objects that were returned and modify the pre-approval or post-approval object to include the new users or groups you would like to add. Then use Update-APReleaseDefinition with the new definition object that you modified.

It would be easier to create either AD groups or Azure Teams/groups and use the groups in place of individual people. Eventually leading to easy maintenance ofr the group members through the Azure DevOps security or AD.