Chef cookbook build pipeline

Overview

Build pipeline is continuous delivery pattern which allows to produce clean and well tested piece of software. In this case I will focus how to implement this pipeline for Chef cookbook.

My helpful screenshot

Description

  • In the first phase (fast feedback) the fastest tests are run for every commit. In this step linting tools such as knife cookbook test, foodcritic for Chef code and tailor for Ruby code can be used for static code analysis (1-sca) and chefspec for unit tests (1-unit-tests).
  • In the second phase (heavy tests) ‘real’ integration tests are run. This step is run if every step from the first phase passes. Here test-kitchen is very useful. It allows you to spin up virtual machine (base on Vagrant, Docker or even Amazon EC2).
  • If the second phase passes the cookbook is uploaded to the Chef server.

My recommendations

  • To implement this I can highly recommend Jenkins and Jenkins Build Flow plugin.
  • You could build phase-0 which pulls a Git repository and then use Clone Workspace SCM plugin to pass the workspace instead of cloning a repo in every plan. This allows you commit isolation.
  • Berkshelf for dependency management and uploading Chef cookbooks.
  • Running plans from the first phase in parallel (if you will use Clone Workspace SCM plugin).