SonarQube API - How to fetch metrics for multiple projects

2.6k views Asked by At

We are using SonarQube ver 5.6.6. My requirement is to fetch metrics for all the projects currently in use, through the SonarQube API. I am able to get the same, using the below API URL.

http://sqserver/api/resources?metrics=ncloc,coverage

The list returned by the API is huge. It includes all the projects created in SonarQube, from the beginning. Many of those projects are not active any more. So, I want to exclude those projects from the API response. How can I achieve this? Is there any way to specify multiple project names in the URL in the same way as we mention multiple metrics.

1

There are 1 answers

3
G. Ann - SonarSource Team On

Try using the api/measures/component service instead. You'll be able to specify componentKey to narrow the result to only the projects you want.