需要查询与TFS中的发布相关的工作项

时间:2018-01-05 15:54:32

标签: tfs

我们最近开始使用TFS来部署发行票,我试图查看与每个发行版相关的工作项数量#但是没有简单的方法可以找到它,有什么建议吗?

1 个答案:

答案 0 :(得分:0)

假设您正在使用vNext构建,您可以使用REST API获取与每个版本相关的工作项数量。

GET http://SERVER:8080/tfs/DefaultCollection/{project}/_apis/release/releases/{releaseId}/workitems

您可以使用以下PowerShell脚本来实现:

#Get the work items associated to Release

$collectionurl = "http://server:8080/tfs/Collection"
$project = "ProjectName"

$ErrorActionPreference = 'SilentlyContinue'

#Get releases
$baseReleasesUrl = "$collectionurl/$project/_apis/release/releases"
$Releases = Invoke-RestMethod -Uri $baseReleasesUrl -Method Get -UseDefaultCredential

#Get the associated work items.
foreach ($release in $Releases.value)
{
$releaseID = $release.id
$baseUrl = "$collectionurl/$project/_apis/release/releases/$releaseID/workitems"            
$response = Invoke-RestMethod -Uri $baseUrl -Method Get -UseDefaultCredential
$wits = $response.value

Write-Host "Release name:" $release.name
Write-Host "Release ID  :" $release.id
Write-Host "Count of Asssociated Work items:"$response.count

      foreach ($wit in $wits)
    {
      Write-Host "Work item ID:" $wit.id
    }
    write-host 

}

enter image description here