Using Puppet Lint with Jenkins

03 July 2012

As the Puppet and Chef developer communities have matured, there has been an increased emphasis on style and sanity checking, also known as “linting.”

In the Chef community the hammer of choice is foodcritic, while Puppet users have puppet-lint to rely on.

Puppet Lint Warnings in Jenkins

Console-based warnings are great for local development, but since we’re already running all our Puppet code through Jenkins for validation, why not let Jenkins track linting as well? This can be easily accomplished with the Jenkins Warnings plugin and a little bit of set up work.

Steps

  1. First make sure you install the Warnings plugin from the Jenkins “Manage Plugins” page
  2. Add a special task to your Rakefile which will invoke puppet-lint with a specific log format, as shown here
  3. Invoke the new Rake task in the build (rake lint:ci)
  4. Configure the Jenkins job to look for the puppet-lint warnings Warnings scan configuration
  5. Run some builds, and enjoy your new puppet-lint reports and trend graphs!

On the build pages you will be able to drill into an overview report such as the one pictured below, hyperlinked to allow you to dig deeper into the specific warnings

Build-specific warnings report


On the job page (http://jenkins/job/my-puppet-module) you will also have a cross-build trend graph to give an indication of the trend of warnings as time goes on.

Overall warnings trend


That’s all there is to it! There isn’t any more setup required to get puppet-lint and Jenkins working together nicely. The hardest part of the whole process seems to be resolving all of the warnings and the second hardest part seems to be keeping the warnings at zero as time progresses.

The Warnings plugin allows for a lot more configuration than I’ve covered in this post, so be sure to explore its more “Advanced” options once you’re up and running!

- R. Tyler Croy