Not able to generate sonarqube report in json format

Must-share information (formatted with Markdown):

  • which versions are you using
    Jenkins: 2.319
    (SonarQube : 9.3 , Scanner, Plugin, and any relevant extension)
  • what are you trying to achieve: wanted to generate JSOn based output
  • what have you tried so far to achieve this : We have sonarqube working and data is reflecting in dashboard which we are building in our jenkins pipeline. But to achieve the json based out we tried below but it is not giving the sonar-report.json file.
 steps{
        withSonarQubeEnv('sonarqube') { 
        sh "mvn sonar:sonar -Dsonar.report.export.path=sonar-report.json"
    }
}

Hi,

Welcome to the community!

Exporting a report directly from analysis was dropped years ago. If you want a report you’ll need to create it after analysis using SonarQube’s Web APIs. You’ll find a link to the on-board documentation in your footer.

 
HTH,
Ann

Thanks for the quick response. I checked Web Api page but couldn’t find a way to generate report in json format. Can you please explain me how this can be done using web api.

Hi,

You’ll use the Web APIs to gather the data you want and then format your own reports. Which APIs? The best way to master the API is to perform the desired action via the UI and eavesdrop to see which calls the UI made to accomplish the action.

 
HTH,
Ann