Checkstyles and docker

33 views
Skip to first unread message

l4n...@gmail.com

unread,
May 19, 2017, 5:28:52 PM5/19/17
to checkstyle
Hi everyone. I am trying to improve my companies code quality. We want Jenkins to launch a docker container, pull in our Android code, run checkstyles, then block Jenkins if there were issues.

So far I have this working. Except the checkstyle jar seems to act oddly. Unlike my intellij plugin, it is listing everything as a warning, and not raising the exit code I want to see. It also doesn't stop the build process like I would like (secondary goal). Any ideas on what I can do to make checkstyles hault my docker and return an error code?

Thanks!

This is the line in my docker file that evokes checkstyle.jar

CMD java -jar ./styleguide/checkstyle-7.7-all.jar -c ./styleguide/checkstyle-master/src/main/resources/google_checks.xml .

Roman Ivanov

unread,
May 19, 2017, 5:34:53 PM5/19/17
to l4n...@gmail.com, checkstyle
please make sure that severity is "error" in your config to have CLI return non 0 exit code

if still a problem - run it on local and make it work as you need, only when try launches in docker.

--
You received this message because you are subscribed to the Google Groups "checkstyle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to checkstyle+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jim Shepherd

unread,
May 19, 2017, 6:35:36 PM5/19/17
to Roman Ivanov, checkstyle
Good call on the warning flag. I couldn't believe there wasn't a command line flag for that. That said it is still a 0. BUT the output is much more nicer when thinking about doing some grep commands. 

Audit done.

Checkstyle ends with 118625 errors.

(Don't judge :-) we didn't do spacing like google. Next week I auto apply changes and adjust the output )

--
-Jim Shepherd

l4n...@gmail.com

unread,
May 19, 2017, 8:42:16 PM5/19/17
to checkstyle, romani...@gmail.com
This is what I came up with. Will try to find a better solution later... As I have to have this command as the last command else it will get over ridden. If I had it earlier I would cut run time in half. But 3 vs 7 mins considering our tests take 40+ 

CMD java -jar ./styleguide/checkstyle-7.7-all.jar -c ./styleguide/rules/google_checks.xml . > ./result.txt | grep "Checkstyle ends with *" | sed "s/[^0-9]//g" | grep '[1-9]' && echo "Failed check styles" && (exit 1);


Roman Ivanov

unread,
May 20, 2017, 12:45:38 AM5/20/17
to l4n...@gmail.com, checkstyle
Remove all javadoc checks and you will make significantly quicker. I recommend to have javadoc validation as separate launch if smb care about speed. Javadoc violations are usually not that critical.
Reply all
Reply to author
Forward
0 new messages