Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get SonarQube Issues Report via API

Is there a way to get an issues report by querying the SonarQube web API?

With previous versions of SonarQube, I was able to generate an HTML report after each build but this feature looks like it's been deprecated in newer installments.

At the moment, I'm trying this bit of code

curl -u foo:bar https://sonar.example.com/api/issues/search?pageSize=100&componentKeys=my-app&metricKeys=violations,ncloc,line

But it errors with {"errors":[{"msg":"The 'component' parameter is missing"}]

Ideally, what I'm after is to just get the lines of code, the number of bugs, vulnerabilities, and Code smells in each run/scan.

Something like thisenter image description here

But through querying the API after each analysis.

Is this possible, please?

like image 972
Hammed Avatar asked Sep 01 '25 16:09

Hammed


1 Answers

Had the same issue. The problem is that there is something wrong with the CURL command and you need to specify the full url as string using quotes.

Your case would be:

curl -u foo:bar "https://sonar.example.com/api/measures/search?pageSize=100&componentKeys=my-app&metricKeys=ncloc,violations,complexity"

This is an example with measures. Be sure to check the required parameters.

like image 113
balsamic Avatar answered Sep 04 '25 09:09

balsamic