0

I have just got the responsibility for around 100 different repositories (applications), distributed on about 20 project in Azure DevOps.

I want to get some (very) basic metrics on each project:

  • Numbers and names of repositories in each project
  • Number of branches in a repository
  • Number of files in a branch
  • Number of code lines in a branch
  • Names of developers which has worked on a project
  • Number of developers which has worked on a project
  • First and last commit/pull request from a developer on a project
  • etc.

Just simple counting and listing. Nothing fancy as test coverage etc. So far all my searching has only given results about code analysis and other advanced stuff. It's not where I am in my tasks right now.

1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Mar 6 at 17:00

1 Answer 1

0

To gather basic metrics on your Azure DevOps projects and repositories, you can use the Azure DevOps REST API. Here’s a general approach to getting the metrics you need:

List of repositories in each project: Use the GET request to {organization}/{project}/_apis/git/repositories?api-version=6.0. This will give you the names and IDs of all repositories in a project.

Number of branches in a repository: For each repository, make a GET request to {organization}/{project}/_apis/git/repositories/{repositoryId}/refs?api-version=6.0. This will list all branches in the repository.

Number of files in a branch: This is trickier because there's no direct API to count files per branch. You might need to clone the repository and use a Git command like git ls-tree -r branchName --name-only | wc -l to list and count files.

Number of code lines in a branch: Similarly, after cloning the repository, you can use a command like git ls-files | xargs wc -l in the branch to get the total lines of code.

Names and number of developers who worked on a project: Use the GET request to {organization}/{project}/_apis/git/repositories/{repositoryId}/commits?api-version=6.0 to fetch commits. From the commit data, you can extract the authors (developers).

First and last commit/pull request from a developer on a project: With the commit data fetched above, you can filter by author and sort by date to find the first and last commit for each developer.

You will need to write scripts that automate these API calls and process the responses to generate your metrics. For authentication, you might use a personal access token (PAT) with your requests to access the Azure DevOps REST API.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.