Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract or export rules from SonarQube

Appriciate if I can get help for the below scenario. My issues to identify how to extract/export all java rules on SonarQube 4.5.7. I tried the below two API calls but I get a "The page you were looking for doesn't exist".

The sonarqube version I have shows 781 java rules my objective is to extract them to an excel or a csv file

[1]curl -X GET -v -u admin:admin http://localhost:9000/api/rules?language=java

[2]curl -X GET -v -u admin:admin http://localhost:9000/api/rules/search?languages=java >> java.json

The second option seems to generate an output but not all 781 rules are extracted thanks,shavantha

like image 526
shavantha Avatar asked Oct 24 '25 04:10

shavantha


1 Answers

URL api/rules/search?languages=java is the correct way to get all Java rules. Response is paginated, so only 10 rules are returned by default :

{ "total": 781, "p": 1, "ps": 10, "rules": [ <here are 10 rules ] }

Use pagination parameter p (page index) for traversing all results. Note that the page size can be changed with parameter ps (defaults 10).

like image 141
Simon Brandhof - SonarSource Avatar answered Oct 27 '25 03:10

Simon Brandhof - SonarSource



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!