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

11,721

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

Share:
11,721
Anders Persson
Author by

Anders Persson

Jag har en civilingenjörsexamen i elektroteknik. Han har 30 års erfarenhet av mjukvaruutveckling, främst inom Telekommunikations och CAD/CAM industrin. Jag är en erfaren verksamhetsutvecklare och har arbetat med distribuerade projekt med deltagare från olika länder i Europa, USA och Asien. Han har också arbetat som projektledare för utvecklingsprojekt och testprojekt i olika organisationer, samt som process och kvalitetsledare.

Updated on June 14, 2022

Comments

  • Anders Persson
    Anders Persson almost 2 years

    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.

  • Anders Persson
    Anders Persson about 8 years
    Thanks, then I think I understand.