Reputation: 1910
I am using VSTS to deploy to remote machines. Before deployment, VSTS asks for PreDeployment approval. Is there any variable or any way to get the name of the approver? I can get it from history but then it is too late. I know how to get the name of the person who triggered the deployment
$(Release.Deployment.RequestedFor)
Microsoft doesn't seem to mention anything
Upvotes: 2
Views: 1872
Reputation: 38106
It seems you want to get the pre-deployment approval during the deployment.
And the pre-defined variables $(Release.Deployment.RequestedFor)
is not used for your situation since it’s the variable shows the display name who create the release (not the user who approve the release before deployment).
To get the pre-deployment approval, you can use the REST API Get release:
GET https://{account}.vsrm.visualstudio.com/{project}/_apis/release/releases/{releaseId}?api-version=4.1-preview.2
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": "marina liu",
"url": "https://app.vssps.visualstudio.com/A2336cdc9-ffd7-41bb-a6cf-19002c9a9d5f/_apis/Identities/18cb43b4-0b0d-43ad-94dc-c8e2b56704c0",
"_links": {
"avatar": {
"href": "https://marinaliu.visualstudio.com/_apis/GraphProfile/MemberAvatars/msa.YjE2YzFlOWUtNWJkYy03NzU1LWJjNWEtNDU4M2Q5ZThlMjk0"
}
},
"id": "18cb43b4-0b0d-43ad-94dc-c8e2b56704c0",
"uniqueName": "****@****.com",
"imageUrl": "https://marinaliu.visualstudio.com/_api/_common/identityImage?id=18cb43b4-0b0d-43ad-94dc-c8e2b56704c0",
"descriptor": "msa.YjE2YzFlOWUtNWJkYy03NzU1LWJjNWEtNDU4M2Q5ZThlMjk0"
},
"id": 0
}
],
"approvalOptions": {
"requiredApproverCount": null,
"releaseCreatorCanBeApprover": true,
"autoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped": false,
"enforceIdentityRevalidation": false,
"timeoutInMinutes": 0,
"executionOrder": "beforeGates"
}
}
Upvotes: 3