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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With