如何获得已经处理过一些错误列表的所有团队成员名称(来自历史记录)

时间:2018-04-13 07:53:22

标签: sql visual-studio tfs azure-devops

如何获取在VSTS(Visual Studio)中处理过一些错误列表的所有团队成员名称(来自历史记录) 我尝试使用历史记录关键字,但它只获得了一个用户结果。我需要处理特定错误的所有人员列表。 ??任何帮助PLZ

1 个答案:

答案 0 :(得分:0)

您可以使用REST API (Revisions - Get)从每个修订版(历史记录)中获取用户信息。

只需尝试以下PowserShell示例,即可让所有团队成员处理特定错误:

注意: 只需在下面的示例中指定正确的参数,如果使用,您需要在磁盘 D 下创建 temp 文件夹直接。

Param(
   [string]$collectionurl = "https://{instance}.visualstudio.com",
   [string]$workitemId = "74",
   [string]$user = "test@hotmail.com",
   [string]$token = "password",
   [string]$templist = "D:\temp\history.txt", # Loop all the records (revisions) with the users who ever changed the specific work item. 
   [string]$userlist = "D:\temp\userlist.txt" # You can get the final users who worked on the specific work item from this text file.

)

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

$baseUrl = "$collectionurl/_apis/wit/workitems/$($workitemId)/revisions?api-version=1.0"            
$response = (Invoke-RestMethod -Uri $baseUrl -Method Get -UseDefaultCredential -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)})
$revisions = $response.value.fields | where({$_.'System.State' -eq 'Committed'}) # Change the sate which you want to get it's changed date here 

#Get the history (revisions) with the changed by user
$witrevisions = @()

foreach($revision in $revisions){

    $customObject = new-object PSObject -property @{
          "ChangedBy" = $revision.'System.ChangedBy'
        } 

    $witrevisions += $customObject      
}


# Output the response to temp txt file.
$witrevisions | Select-Object `
                ChangedBy | Out-File -FilePath $templist -Width 200


# Remove the duplicated records.
$hash = @{}      # define a new empty hash table
 gc $templist |  %{if($hash.$_ -eq $null) { $_ }; $hash.$_ = 1} >  $userlist

enter image description here