Findbugs for Git Pull Request
Is there a way to setup Findbugs (or any other static code analysis tool) in Jenkins to analyse the incoming pull requests and compare the result with the main branch? My goal is to reject pull requests which increase the number of static code analysis issues.
One Solution collect form web for “Findbugs for Git Pull Request”
You can realize your idea by using the Maven-plugins checkstyle, findbugs and pmd (-cpd).
Each of this plugin has a “:check”-mojo, which can fail the build – based on zero or configured rule-violations.
- checkstyle check-mojo
- findbugs check-mojo
- pmd check-mojo
- pmd-cpd check-mojo
This mojos are bound to the maven-“verify”-phase, so mvn verify will do the job – or you execute the mojos directly within your jenkins-build (job-configuration “Build” -> “Goals and options” -> mvn verfiy, or mvn test checkstyle:check).
The plugins have different ways to configure a fail.
For example, checkstyle-plugin has maxAllowedViolations-configuration-parameter. So you can set this parameter to your current violations-count, and use mvn verfiy or mvn checkstyle:check to let your build fail, if a new violation occurs. Of course, you would have to increase this parameter every time a checkstyle-violation is fixed.
In fingbugs-plugin, your build would have to be free of violations, before you can use mvn findbugs:check.