-
Bug
-
Resolution: Fixed
-
Major
-
-
3.0.2
private static final String SONAR_ISSUES_BASE_URL = "/api/issues/search?ps=1&projectKeys=";
I don't believe this URL is getting what you expect. It returns the total number of issues in the entire sonarqube system whether you have the projectKeys request parameter or not.
I believe to get the issues by project you need the following:
$sonarurl="${SonarHostUrl}api/measures/component?metricKeys=code_smells,ncloc,duplicated_lines_density,open_issues,sqale_rating,critical_violations,blocker_violations,major_violations,vulnerabilities,complexity,sqale_index,sqale_debt_ratio,violations&component=$SonarProjectKey"
You have to specify the metrics you want returned
Then on the returned JSON, you need to get:
$sonmeasures=$sonresult.component.measures
This object will contain the metrics only for the project you are looking for.
I'd be happy to talk further if anything isn't clear. I love this plugin, btw. Makes our grafana dashboards very helpful.
Yes, i'm talking about when you get the total amounts of the different issue severities. If you have multiple/many projects in sonarqube, that will return the total across all projects, as in
Project_1: 2 INFO issues
Project_2: 5 INFO issues
Project_3: 10 INFO issues
This call: /api/issues/search?ps=1&projectKeys=Project_1 will return 17 INFO issues total in sonarqube version:
This could be because of the version of Sonarqube I'm using. I haven't tried upgrading to see if it's fixed. But I did confirm if you use the /api/measures/component, and ask for the Issues with metric keys: "info_violations, major_violoations, critical_violations" the data does come up per project as expected.