<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="/feed.xml" rel="self" type="application/atom+xml" /><link href="/" rel="alternate" type="text/html" /><updated>2026-08-06T21:16:34+00:00</updated><id>/feed.xml</id><title type="html">Kerryhouse</title><subtitle>Having fun and building cool things.
</subtitle><entry><title type="html">Test Kitchen, Inspec, and Jenkins Reporting</title><link href="/chef/2016/11/18/kitchen-inspec-jenkins.html" rel="alternate" type="text/html" title="Test Kitchen, Inspec, and Jenkins Reporting" /><published>2016-11-18T05:00:00+00:00</published><updated>2016-11-18T05:00:00+00:00</updated><id>/chef/2016/11/18/kitchen-inspec-jenkins</id><content type="html" xml:base="/chef/2016/11/18/kitchen-inspec-jenkins.html"><![CDATA[<blockquote>
  <p>This functionality released in inspec 1.6.0 on 11/28/2016</p>
</blockquote>

<p>We’ve standardized our kitchen verifier on
<a href="https://github.com/chef/inspec">Inspec</a> 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
<a href="https://github.com/windyroad/JUnit-Schema">JUnit xml format</a>. We’re lucky
because unlike chefspec Inspec operates on the host rather than the kitchen vm.
This means that we can use Inspec’s <code class="language-plaintext highlighter-rouge">--format JUnit</code> option and consume it with
jenkins reporting.</p>

<h1 id="cookbook-testing-with-inspec">Cookbook Testing with Inspec</h1>

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

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="ss">verifier:
  name: </span><span class="n">inspec</span>
  <span class="ss">format: </span><span class="n">junit</span>
  <span class="ss">output: </span><span class="p">.</span><span class="nf">/</span><span class="n">inspec_output</span><span class="p">.</span><span class="nf">xml</span>
</code></pre></div></div>

<p>The <code class="language-plaintext highlighter-rouge">format:</code> option corresponds with the <code class="language-plaintext highlighter-rouge">--format cli</code> 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.</p>

<p><img src="/assets/images/kitchen-inspec-placement.png" alt="Kitchen inspec tests location" /></p>

<p>See <a href="https://github.com/jkerry/CookbookResume">my resumé</a> for an example.</p>

<h1 id="jenkins-configuration">Jenkins Configuration</h1>

<p>Now that you’ve got a a target you can use inspec’s cli <code class="language-plaintext highlighter-rouge">--format junit</code> 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:</p>

<p><img src="/assets/images/junit-post-build.png" alt="JUnit Post Build Reporting" /></p>

<p>and Bam! you’ve got web ui test results and aggregation.</p>

<p><img src="/assets/images/test-results.png" alt="Test Results" /></p>

<p><img src="/assets/images/test-aggregation.png" alt="Test aggregation" /></p>

<p>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..</p>]]></content><author><name></name></author><category term="chef" /><summary type="html"><![CDATA[This functionality released in inspec 1.6.0 on 11/28/2016]]></summary></entry></feed>