Reputation: 1
I am using Jenkins
as our build tool. I don't want System.out.println
to be there in the code. Is there a way by which we can add a hook which will check this. And if any .java
file is detected with System.out.println
then fail the build.
Upvotes: 0
Views: 166
Reputation: 7489
If you want to "Jenkins-ize" this, set up Jenkins to run with Sonar, and add a rule in Sonar that fails if System.out.println is found.
Advantages: - you can run nightly sonar builds - you can add more than that one rule (and you should ;)) - you will check code on the whole branch, not just yours.
Upvotes: 0
Reputation: 45243
You can use a static code analysis tool. For example PMD (https://pmd.github.io/pmd-5.3.3/index.html) .
You can specify a rule that checks for calls to System.out.println
.
How to write a rule: https://pmd.github.io/pmd-5.3.3/customizing/howtowritearule.html
You can analyze your code with PMD over Jenkins via the PMD plugin: https://wiki.jenkins-ci.org/display/JENKINS/PMD+Plugin
There are some good tutorials for using PMD with Jenkins. A good one is this: https://www.youtube.com/watch?v=aRgYd-SLyrs
Upvotes: 1