Azure DevOps - getting project stats for all projects

If you have quite a lot of projects in your Azure DevOps organization and is looking for a way to filter the inactive projects out, that’s what  we will discuss today.

 

This is going to be based on the data the we see in the "Project stats" section on the landing page of an ADO project. This data gets fetched using the  "Contribution/HierarchyQuery/project" REST Api, which for some reason doesn't seem to be documented. So we may have to keep an eye out for any changes.



 

The apis lets you get project stats like:

  1. Work Items : created and updated
  2. Repos : Commits pushed with the number of authors, PRs created and completed

the range can be specified, and accepts a maximum value of 30 days.


If you use TFVC, that data is also returned - like the number of changesets and authors. I am not using it for the calculation here as we don't use TFVC. You can also get the metrics for builds and releases - just in case you are interested, the api for build metrics looks like: 

https://dev.azure.com/{orgname}/{projectid}/_apis/build/Metrics/Daily?minMetricsTime=2020-05-09T14%3A16%3A11.100Z

 

And the one for release looks like: 

https://vsrm.dev.azure.com/{orgname}/{projectid}/_apis/Release/metrics?minMetricsTime=2020-05-09T00%3A00%3A00.000Z

  

The below script checks if there was any activity on boards or repos for the projects, for the last 30 days - and then if there was none, will mark them as inactive. It just checks whether the sum of the stats for Work Items and Repos is 0. The script takes the organization name and a pat with collection level rights as the inputs, and the output is a csv file with the project stats exported.

 

Hope you find this useful!


Comments

Popular posts from this blog

Export the members of a project level group from all the projects in an Azure DevOps

Managing user licenses and cost for Azure DevOps.