How to extract or export rules from SonarQube

2019-07-08 05:16发布

问题:

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

回答1:

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).



回答2:

http://localhost:9000/api/rules/search?languages=java

the url parameter is languages rather language