sonarqube java api to fetch all the Issues/Violations for a project
sonarqube
Solution
I think you've found the answer to this question by now. However, I'll go ahead and answer this one. There are two ways of fetching all the issues of a particular project.
- Using the webservice sonarqube exposes. http://docs.sonarqube.org/pages/viewpage.action?pageId=2392181#WebService/api/issues-GetaListofIssues
- Using a sonar plugin How to code a custom sonar plugin? https://github.com/SonarSource/sonar-custom-plugin-example
How to get all the issues- Use 'ProjectIssues' BatchComponent to list all the issues using org.sonar.api.issue.ProjectIssues.issues()
Use @DependsUpon(DecoratorBarriers.ISSUES_TRACKED) annotation on your decorator. This will make sure that the decorator is executed once issues are tracked as stated in the documentation.
Extract from DecoratorBarriers class:
/**
* This barrier is after {@link #ISSUES_ADDED}. The decorators that need to list all issues must be declared
* after this barrier : {@code @DependsUpon(value=DecoratorBarriers.ISSUES_TRACKED)}
*
* @since 3.6
*/
String ISSUES_TRACKED = "END_OF_VIOLATION_TRACKING";
`
Problem
I am using the sonar web api to query the sonar server for violations. Is there a java code to fetch all the Issues/Violations of a particular project in sonarqube? Please, any suggestions?