TFS 2017 Update 3.1发行批准报告/历史记录

时间:2018-10-05 10:57:39

标签: tfs

请帮助获取有关TFS 2017更新3.1中每个版本定义的版本批准者列表。

感谢与问候

1 个答案:

答案 0 :(得分:1)

您可以调用REST API(Definitions - Get)来检索批准者列表。

下面的PowerShell脚本可以获取每个版本定义的“发布批准者”列表:(只需相应地替换参数)

Param(
   [string]$baseurl = "http://SERVER:8080/tfs/DefaultCollection",  
   [string]$projectName = "0511ScrumTFVC",
   [string]$user = "Domain\user",
   [string]$token = "password/PAT"
)

# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))

$releasesuri = "$baseurl/$projectName/_apis/release/definitions"
$releasesresult = Invoke-RestMethod -Uri $releasesuri -Method Get -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
$redids = $releasesresult.value.id

foreach ($redid in $redids)
{
    $uri = "$baseurl/$projectName/_apis/release/definitions/$redid"
    $approvers = Invoke-RestMethod -Uri $uri -Method Get -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}

    $preApprovers = $approvers.environments.preDeployApprovals.approvals.approver.displayName
    $postApprovers = $approvers.environments.postDeployApprovals.approvals.approver.displayName

    write-host "Release ID: $redid - preApprovers:"
    foreach ($preApprover in $preApprovers)
    {
      write-host $preApprover
    }
    write-host "`nRelease ID: $redid - postApprovers:"

    foreach ($postApprover in $postApprovers)
    {
     write-host $postApprover
    }
}