Anders Persson
Anders Persson

Reputation: 337

How to get the sonar-report.json file created with sonarqube?

I am runnig Sonarqube 5.3 and has integrated it with Jenkins. I want to post Sonareqube issues as Gerrit comments.

Then I need to specify the path to and name of the data generated from sonarqube, e.g. build/sonar/sonar-report.json

The file sonar-report.json is not generated and I have found some setting for Sonarqube that shouold make sonareqube create the file.

sonar.report.export.path=sonar-report.json
sonar.issuesReport.html.enable=true
sonar.issuesReport.json.enable=true
sonar.issuesReport.console.enable=true

I have tried to set these in the file

<sonar-installation-directory>/conf/sonar.properties

I have restarted the Sonare service and restarted the computer but the sonar-report.json file is still not created.

Upvotes: 2

Views: 15574

Answers (1)

Nicolas B.
Nicolas B.

Reputation: 7321

Those properties are not meant to be configured on the server side, they are passed on the scanner side, and are valid only for analysis in preview mode (by the way no need for sonar.issuesReport.json.enable). That's what SonarLint for Command Line is about.

Why preview mode ? Because the goal is to analyse a diff (to comment the code review in your case). You don't want a full analysis to be submitted to SonarQube if the code is not yet pushed to the repo.

Example:

$ sonar-runner -Dsonar.analysis.mode=preview -Dsonar.issuesReport.html.enable=true -Dsonar.report.export.path=report.json -Dsonar.host.url=http://localhost:9000 
[...]
$ ls .sonar/
issues-report  report.json

(careful with the JSON report, looks like it will ultimately be removed, see SONAR-7247)

P.S.: I guess you might be using the sonar-gerrit Jenkins plugin, which is essentially saying the same thing:

This plugin is intended to work with report provided by SonarQube running on your project in preview mode

Upvotes: 5

Related Questions