We are currently using SonarQube version 6.7. We have a need to build analytics data store to report metrics out of Sonar especially how the projects have performed in the past scans etc. I have built the following API to get the project and its metics
api/measures/component?format=json&component=pb&metricKeys=ncloc,violations,new_vulnerabilities,critical_violations,major_violations,blocker_violations,tests,test_success_density,test_errors,test_failures,coverage,line_coverage,sqale_index,alert_status,quality_gate_details&includealerts=true
How do I change the API above to:
Get metrics information for all projects. I tried putting a comma but it did not work.
Add language and project scan date i,e, I need to report on multiple scans for a given project?
You can’t. You’ll need to iterate over the projects of interest.
For that you want api/measures/search_history. For language, you’ll want to request the value of ncloc_language_distribution. Note that this is a DATA format metric, so it returns something like this:
The API, api/measures/search_history would not return the project name attribute. How do I differentiate the projects in the result set when I iterate the projects I need. Please clarify.
If you’re iterating over the projects of interest, then you should already know which project the current request is for…
Explicitly, if you’re interested in projects A, B, and C, you already know that querying for &component=A,B,C doesn’t work. Instead, you need to do something like (pseudo code):
for (project in A,B,C) {
api/measures/component?component=**${project}**&...