[英]Azure DevOps - The time a WorkItem spends in specific columns on the kanban board
我想報告功能在我們看板的每一列中花費的天數。
因此,對於我想要的示例輸出,我們有一個帶列的看板:
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"
注意:您需要更改當前日期格式,您可以參考此文檔了解更多詳細信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.