Before we proceed with Jenkins, allow me to introduce the two new helpers – Packer and Serverspec.
"Packer is a tool for creating machine and container images for multiple platforms from a single source configuration."
Essentially, Packer is going to, well, pack things for us. We will feed it a template, based on which it will launch an EC2 instance, perform requested tasks (over SSH), then create an AMI from it. Packer can talk to various platforms (AWS, GCE, OpenStack, and so on) to provision resources via local shell, remote (SSH), ...