I need to fetch unit test coverage data for new code changes via the api. The metrics. I can see the data in SonarQubeDashboard but the api is not returning any values for the metrics like:
I am invoking the api :
https:///api/resources?format=json&metrics=ncloc,line_coverage,new_line_coverage
Even the Public Nemo Instance does not return these metric values:
The above API is returning only ncloc and line_coverage for each and every project.
Please dont tell me to check if these metrics are not available in the version. They are, if you invoke the API:
SonarQube's api/resources
Web API is deprecated, you should use api/measures/component
instead (since 5.4).
Using this project as an example:
If you're really stuck with api/resources
(e.g. old SonarQube version), then keep in mind that for new metrics there is a notion of time delta (new since when ?), so you have to add includetrends=true
to your request. Let's do that with your example:
This gives you new_coverage
and new_line_coverage
(for the projects which do have coverage and SCM information available).