This functionality released in inspec 1.6.0 on 11/28/2016

We’ve standardized our kitchen verifier on Inspec at my corner of NCR and we’re in need of a solution for reporting test-kitchen runs from pull request verifiers in jenkins. The default test reporting format for most jenkins jobs is the JUnit xml format. We’re lucky because unlike chefspec Inspec operates on the host rather than the kitchen vm. This means that we can use Inspec’s --format JUnit option and consume it with jenkins reporting.

Cookbook Testing with Inspec

If you’d like to switch your cookbook’s default verifier to inspec change your .kitchen.yml verifier to match something like the following:

verifier:
  name: inspec
  format: junit
  output: ./inspec_output.xml

The format: option corresponds with the --format cli option. you’ll likely need the kitchen-inspec gem. Note the output file location for Jenkins. It might be worth noting that the test location in your cookbook will change with the verifier name.

Kitchen inspec tests location

See my resumé for an example.

Jenkins Configuration

Now that you’ve got a a target you can use inspec’s cli --format junit argument or kitchen-inspec’s junit xml output all you need to do is consume the junit xml as a post-build event in Jenkins. This comes with the stock installation and is is the defacto way to aggregate test results in jenkins:

JUnit Post Build Reporting

and Bam! you’ve got web ui test results and aggregation.

Test Results

Test aggregation

Now the only thing left to do is for me to fix the errors in my cover letter so we don’t have any embarrassing failures to report..