James
James

Reputation: 313

How can you show work items that are being moved into the 'next' sprint repeatedly in Azure DevOps

With our DevOps org, we've got an issue with people using their sprint planning time to dump everything unfinished from the last sprint into the next. It's quite frustrating since this is the very opposite of planning - all that's happening is that the work that people couldn't achieve last time gets moved to another sprint that they're unlikely to get through, so it will continue to be something that they almost come to.

I need to find a way of surfacing this so it can be challenged. I know it happens, and have a few examples, but I need to understand how deep the problem goes.

Is there a way to query/report on work item history for the number of sprints it's been in??

Upvotes: 2

Views: 3156

Answers (1)

Vito Liu
Vito Liu

Reputation: 8278

We could list the work item history to check the number of sprints it's been in.

Note: we need check the field System.IterationPath

REST API:

GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{id}?api-version=6.0

Result:

enter image description here

Power shell script:

$connectionToken="{PAT}"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)"))
$WorkItemHistoryURL = "https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{id}?api-version=6.0" 
$WorkItemHistoryInfo = Invoke-RestMethod -Uri $WorkItemHistoryURL -Headers @{authorization = "Basic $base64AuthInfo"} -Method Get 

Write-Host "The IterationPath is" $WorkItemHistoryInfo.value.fields.'System.IterationPath'

Result:

enter image description here

Update1

We cannot list all user stories via WIQL query, and then list the history and get the field System.IterationPath

Note: If you want to query org level work item, just delete [System.TeamProject] = @project

Power shell script:

$connectionToken="{PAT}"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)"))
$WorkItemQueryURL = "https://dev.azure.com/{org name}/{project name}/{team name}/_apis/wit/wiql?api-version=6.0" 

$body =@"
{
  "query": "Select [System.Id], [System.Title], [System.State] From WorkItems Where [System.TeamProject] = @project and [System.WorkItemType] = 'User Story' 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

ForEach ($ID in $WorkItem.workItems.id)
{
$WorkItemHistoryURL = "https://dev.azure.com/{org name}/{project name}/_apis/wit/workItems/$($ID)/revisions?api-version=6.0" 
$WorkItemHistoryInfo = Invoke-RestMethod -Uri $WorkItemHistoryURL -Headers @{authorization = "Basic $base64AuthInfo"} -Method Get 

Write-Host "The work item" $ID "IterationPath is" $WorkItemHistoryInfo.value.fields.'System.IterationPath'

}

Result:

enter image description here

Upvotes: 2

Related Questions