【发布时间】:2018-04-13 07:53:21
【问题描述】:
如何获取所有在 VSTS (Visual Studio) 中处理过一些错误列表的团队成员姓名(来自历史记录) 我曾尝试使用 History 关键字,但它只给我一个用户结果。我需要处理特定错误的所有人员列表。 ??任何帮助PLZ
【问题讨论】:
标签: sql visual-studio tfs azure-devops
如何获取所有在 VSTS (Visual Studio) 中处理过一些错误列表的团队成员姓名(来自历史记录) 我曾尝试使用 History 关键字,但它只给我一个用户结果。我需要处理特定错误的所有人员列表。 ??任何帮助PLZ
【问题讨论】:
标签: sql visual-studio tfs azure-devops
您可以使用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
【讨论】: