Creating SonarQube HTML report in CentOS (Works in any OS) …

Install the sonar-report using npm:

npm install -g https://github.com/soprasteria/sonar-report.git

Now run the command :

replace –sonarurl with your sonarqube server base url

replace –sonarcomponent with the project id which you want to retrieve (just navigate to projects>project and get the id from url)

if you want your report to have all reported issues like Bugs,Code smells, and vulnerabilities. update –all bugs to true , else leave it as false so that only issues with vulnerabilities tag will be available in report.

On running below command, report will be created in /tmp/:

 sonar-report \
--sonarurl="http://localhost:9000" \
--sonarcomponent="Juice" \
--project="Sonar Report" \
--application="sonar-report" \
--release="1.0.0" \
--sinceleakperiod="false" \
--allbugs="true" > /home/Fullreport.html 

Final report :

image

Ignore the below steps, as it was for the old version of sonar-report. Now this is done through the argument –allbugs.

search for the sonar-report installation :

sudo find / -name sonar-report

navigate to the lib directory from the search result

cd <path>/node-v10.16.0-linux-x64/lib/node_modules/sonar-report

Edit the index.js

vi index.js

search for ‘types=VULNERABILITY &’ and remove it

final file will look like this:

image