According to your description, looks like you just want to get the pre-deployment approval during the deployment.
To get the pre-deployment approval, you can use the REST API Get release:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}?api-version=5.1`
For the release id, you can use the predefined variable $( Release.ReleaseId)
. And you can get the per-deployment approval from the response as below:
"preApprovalsSnapshot": {
"approvals": [
{
"rank": 1,
"isAutomated": false,
"isNotificationOn": false,
"approver": {
"displayName": "yeye",
"url": "xxx",
"_links": {
"avatar": {
"href": "xxx"
}
},
"id": "18cb43b4-0b0d-43ad-94dc-c8e2b56704c0",
"uniqueName": "****@****.com",
"imageUrl": "xxx",
"descriptor": "msa.YjE2YzFlOWUtNWJkYy03NzU1LWJjNWEtNDU4M2Q5ZThlMjk0"
},
"id": 0
}
],
"approvalOptions": {
"requiredApproverCount": null,
"releaseCreatorCanBeApprover": true,
"autoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped": false,
"enforceIdentityRevalidation": false,
"timeoutInMinutes": 0,
"executionOrder": "beforeGates"
}
}
Finally, you could use the got approver ID/Name, comments and pass them as an argument to a powershell script.
Hope this helps.