谁批准了VSTS中的部署? [英] Who approved the deployment in VSTS?
问题描述
我正在使用VSTS部署到远程计算机.部署之前,VSTS要求获得部署前批准.是否有任何变量或任何方式来获取批准人的名字?我可以从历史中得到它,但是为时已晚.我知道如何获取触发部署的人的姓名
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)
推荐答案
似乎您想在部署过程中获得部署前的批准.
It seems you want to get the pre-deployment approval during the deployment.
并且预定义的变量 $(Release.Deployment.RequestedFor)
不会用于您的情况,因为该变量显示创建发布的显示名称(而不是批准发布的用户)部署之前).
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
对于发行版ID,可以使用预定义的变量 $(Release.ReleaseId)
.您可以从响应中获得按部署的批准,如下所示:
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"
}
}
这篇关于谁批准了VSTS中的部署?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!