Better Chef Reporting for Automated Pipelines

Featured image for sharing metadata for article

When building your Chef cookbooks, you likely will want an automated pipeline which allows you to enforce a quality bar for how your cookbooks are developed.

However, you probably want a little more visibility than "did that build succeed", and want to be able to drill into exactly what failed. To do this, across many automated build platforms, like Jenkins, you want to produce a (well) supported machine-parseable format.

One of the most commonly usable formats is the JUnit output format, made popular with the Java testing library JUnit.

Fortunately, all of the Chef tools that we would want to use in a pipeline support the JUnit report format.

Cookstyle

Because Cookstyle is built upon the wonderful Rubocop, which means we can use the inbuild formatters that Rubocop provides, such as the built-in JUnit formatter:

rubocop --format junit --out test-reports/junit.xml
# or, only show failed Cops
rubocop --format junit --out test-reports/junit.xml --display-only-failed

RSpec

Unfortunately RSpec doesn't, out of the box, support JUnit format, but there's a great gem rspec_junit_formatter which when installed, allows us to run:

rspec --format RspecJunitFormatter --out test-reports/rspec.xml

Test Kitchen + InSpec

Test Kitchen fortunately supports JUnit format results out-of-the-box:

verifier:
  name: inspec
  reporter:
    - cli
    - junit:path/to/results/%{platform}_%{suite}_inspec.xml

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

#blogumentation #chef #jenkins #test-kitchen #rubocop #cookstyle #rspec.

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.