How to configure a checkstyle in Jenkins

Last time, we set up a job checkstyle check locally. But for this test to be truly meaningful and to benefit the team, it is better to integrate this action into the CI / CD of your development process.

In this article, we will look at setting up checkstyle checking using the example of the popular jenkins automation server.

I assume that you already have configured jenkins and you already know how to run the checkstyle check locally.

Let’s create a base project with a project build in maven. Add the script from this article to the jenkins pipeline.

Plugin installation

In order to display the check results, we need to install the  Warnings Next Generation Plugin
Manage Jenkins> Plugin Manager> Available Enter name of plugin – Warnings Next Generation and install it

installation warning next generation plugin in jenkins

Configure jenkins to save checkstyle results

Let’s configure JDK and Maven to build the project. Go to Manage Jenkins> Global Tool Configuration
In the Maven section, click Add Maven.

maven tool installation in jenkins

Remember text you entered in the name field. Repeat same actions for jdk section.

jdk installation in jenkins

Now time to write pipeline script

parallel keyword allow step to be executed in parallel

record our chesckstyle issues to report.

Now, run a job and see result. Click on Checkstyle Warning link in job details,  We see detailed information about checkstyle checks, their level as well as the history of the last several builds.

jenkins next generation plugin checkstyle report

 

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.