In Azure Devops, how can I query all the user stories and the number of related bugs for each story? Can I create a report/view and schedule sending it to an email address?
Overall, I need a manager’s view of all user stories and the number of bugs under each one.
Screenshot for illustration: https://i.sstatic.net/fKiLl6ta.png
2
Answers
There is no built-in feature to send the view/query result to email on schedule. You need to do it with automation tool like Power Automate…etc.
Your query will not list the user story which
doesn't
have Bugs related, useReturn all top level items
forFilter option
to get all user stories even no bugs related.The user story could have multiple types links, like Bug, tasks, Feature…etc. In DevOps query,
it cannot only count the related bug
, but count all related links(addRelated Link Count
column on query result). If you would like to seethe count of related bug
, you can checkBacklog
page, add arollup column
namedCount of Bug
as below.As mentioned before, for schedule sending it to an email, you need to achieve it with automation tool, like Power Automate…etc.
Main steps as below:
Recurrence
trigger to set the schedule (e.g., daily, weekly).Get Query Results
action, connect to your Azure DevOps organization and project, choose the query you want to run.Use the
Create HTML Table
action to format the query results into an HTML table.Add the
Send an Email
action, specify the recipient’s email address, subject, and body. Include the HTML table in the body of the email.You can set up a pipeline with the scheduled triggers. And in the pipeline, you can call the Azure DevOps REST API "Send Mail – Send Mail" to send email for the query result to the specified users.
Below is the sample with the detailed steps to set up the configurations:
Create a Work Item query like as below image shows. It will returns all the User Stories and the linked Bugs of them within a project. From the URL of this query, you can see its ID.
The WIQL of this query looks like below. It will be used when calling the "Send Mail" API.
In the project where the Work Item query is in, have a repository that contains a pipeline YAML file and a PowerShell script file.
The content of PowerShell script (
wiql-result-send-email.ps1
).wiql-result-send-email.yml
).Use the YAML file
wiql-result-send-email.yml
to create a YAML pipeline.Since the pipeline has been configured a scheduled trigger, it will automatically trigger a run of this pipeline everyday. at this time, the run will use the default values of parameters and pass them into the PowerShell script for use.
If you manually trigger this pipeline, you can enter different values to override the default ones.
The content of the email message will look like as below.