我想报告一下我们看板的每一列中功能花费的天数。
因此,对于我想要的示例输出,我们有一个带有列的看板:
Funnel --> Workitem X spend 10 days in here
Analyzing --> Workitem X spend 13 days in here
Backlog --> Workitem X spend 3 days in here
Implementing --> Workitem X spend 11 days in here
Done --> Workitem X spend 50 days in here
到目前为止我尝试过
你们知道我可以检索有关功能及其 BoardColumns 的历史数据的任何方法吗?
提前致谢, 乔斯特
我们可以使用 Rest API 和 power shell 来做到这一点。
示例脚本:
$connectionToken="pat"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)"))
$WorkItemQueryURL = "https://dev.azure.com/{organization}/{project}/{team}/_apis/wit/wiql?api-version=6.0"
$body =@"
{
"query": "Select [System.Id], [System.Title], [System.State] From WorkItems Where [System.WorkItemType] = 'User Story' AND [State] = 'Closed' order by [Microsoft.VSTS.Common.Priority] asc, [System.CreatedDate] desc"
}
"@
$WorkItem = Invoke-RestMethod -Uri $WorkItemQueryURL -ContentType "application/json" -Body $body -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method POST
Write-host $WorkItem.workItems.id
结果:
Microsoft.VSTS.Common.StateChangeDate
的值获取工作项,就是状态发生变化的时间,然后我们就可以计算出从状态变为xxx
到现在已经处于这个状态了多少天
.示例脚本:
Write-host $WorkItem.workItems.id
ForEach ($ID in $WorkItem.workItems.id)
{
$WorkItemInfoURL = "https://dev.azure.com/v-viliu/test/_apis/wit/workitems/$($ID)?api-version=6.0"
$WorkItemDetail = (Invoke-RestMethod -Uri $WorkItemInfoURL -Method Get -UseDefaultCredential -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)})
$StateChangeDate = $WorkItemDetail.fields."Microsoft.VSTS.Common.StateChangeDate"
Write-host "Work item ID: $ID and StateChangeDate is $StateChangeDate"
}
结果:
示例脚本:
$current = Get-Date
$SpendDate= New-TimeSpan -Start $current -End $StateChangeDate
Write-Output "The spend date is: $SpendDate"
注意:您需要更改当前的日期格式,您可以参考此doc了解更多详细信息。
不是为了复活旧线程,而是,TL;DR:我遇到了类似的问题,并在我的Github上发布了解决方案。
如果您的每个列都有自己独特的状态,则上述 Vito 的解决方案将适合您,但它只能告诉您工作项在基于 Today 的当前状态下花费了多长时间。 它无法向您显示工作项目全面移动的历史视图。
我上面提供的解决方案并不像仅提供报告的 Power Shell 脚本那么简单,它是一个捕获工作项所在看板列的历史更改的过程,允许您运行类似于以下内容的报告如下图所示。
SELECT DISTINCT
wi.WitID,
DATEDIFF(day, wic_new.AuditCreatedDate, Coalesce(wic_prog.AuditCreatedDate, wic_released.AuditCreatedDate, GETDATE())) as DaysInNew,
DATEDIFF(day, wic_prog.AuditCreatedDate, Coalesce(wic_released.AuditCreatedDate, GETDATE())) as DaysInProgess,
DATEDIFF(day, wic_released.AuditCreatedDate, GETDATE()) as DaysInReleased
FROM WorkItems wi
LEFT JOIN WorkItem_ColumnHistory wic_new on (wic_new.WitID = wi.WitID AND wic_new.CurrentColumn = 'New' AND wic_new.WefColumnID LIKE '%[YOUR TEAMS WEF ID]%')
LEFT JOIN WorkItem_ColumnHistory wic_prog on (wic_prog.WitID = wi.WitID AND wic_prog.CurrentColumn = 'In Progress' AND wic_prog.WefColumnID LIKE '%[YOUR TEAMS WEF ID]%')
LEFT JOIN WorkItem_ColumnHistory wic_released on (wic_released.WitID = wi.WitID AND wic_released.CurrentColumn = 'Released' AND wic_released.WefColumnID LIKE '%[YOUR TEAMS WEF ID]%')
WHERE
wi.[State] NOT IN('Closed', 'Removed')
ORDER BY WitID ASC
此查询的解释位于链接的 GitHub 存储库的 ReadMe 文件中,因此我不会在此处重复解释。基本上,此查询会查看从 Azure DevOps 获取的历史数据,然后显示一个结果集,该结果集显示工作项在看板板的每一列中存在的时间。
我使用此扩展来计算工作项目在每个状态的工作流程中花费的时间https://marketplace.visualstudio.com/items?itemName=SaaSJet.tis-azure.
希望这对您有帮助!