clug 2014-10 - cookbook ci with jenkins
DESCRIPTION
An overview of how I'm using Chef to automate Jenkins to test Chef cookbooks.TRANSCRIPT
![Page 1: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/1.jpg)
Cookbook CI with Jenkins
Part 1
![Page 2: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/2.jpg)
Who Am I?
• "zts" most places on the internet
• Mostly Ops, Background, Mostly
• Co-founder Elastera
![Page 3: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/3.jpg)
Who Are You?
![Page 4: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/4.jpg)
Cookbook Testing
• foodcritic, chefspec, test-kitchen
• Get things right
• Keep things right
![Page 5: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/5.jpg)
![Page 6: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/6.jpg)
CI Servers
• System for running actions on every commit
• Identify problems early
• Jenkins, GoCD, TravisCI, Wercker, etc
![Page 7: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/7.jpg)
Why Jenkins?
• Mature
• Extensible
• Good Chef Cookbook
• Free
![Page 8: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/8.jpg)
Why Not Jenkins?
• TMTOWTDI
• XML, so much XML
• Automation is not a joy
![Page 9: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/9.jpg)
Jenkins Cookbook
• Install Jenkins & Plugins
• Create jobs
• Run commands and scripts
![Page 10: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/10.jpg)
Previously…
• Cooking With Jenkins
• ...and Kitchen, and Docker
![Page 11: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/11.jpg)
Subsequently…
• Federated Jenkins with Chef
• github:erichelgeson/jenkins-chef-dsl/
![Page 12: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/12.jpg)
Basic Configuration
• Install Plugins
• Configure Plugins
• Configure Jenkins
![Page 13: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/13.jpg)
Installing Plugins
• Idempotent
• No dependency resolution
• Restart may be required
![Page 14: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/14.jpg)
Plugin Configuration
• XML :(
• ...containing module version strings :((
• Hold nose and use cookbook_file
![Page 15: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/15.jpg)
Jenkins Configuration
![Page 16: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/16.jpg)
Creating Jobs
• jenkins_job
• Job DSL plugin
• Jenkins Job Builder
![Page 17: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/17.jpg)
![Page 18: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/18.jpg)
![Page 19: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/19.jpg)
Pipeline
• Foodcritic
• Chefspec
• Kitchen
• Publish
![Page 20: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/20.jpg)
And after publish?
• That's why this is Part 1...
![Page 21: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/21.jpg)
Foodcritic
• Warnings plugin :)
• XML config :(
![Page 22: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/22.jpg)
![Page 23: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/23.jpg)
![Page 24: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/24.jpg)
Chefspec
• yarjuf gem
• Publish JUnit test result report
![Page 25: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/25.jpg)
![Page 26: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/26.jpg)
![Page 27: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/27.jpg)
Test Kitchen
• kitchen-docker
• Matrix jobs
• EnvInject and AnsiColor plugins
![Page 28: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/28.jpg)
![Page 29: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/29.jpg)
Berkshelf
• upload to Chef server
• record version as artifact
![Page 30: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/30.jpg)
![Page 31: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/31.jpg)
Berkshelf
• curl -s https://jenkins.example/job/berks-upload/lastSuccessfulBuild/artifact/VERSION
![Page 32: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/32.jpg)
Gluing it together
• Publish Artifact
• Copy Artifact
• Build Pipeline
![Page 33: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/33.jpg)
Pipelines
• Build Pipeline plugin
• Build Graph View plugin
• Build Flow DSL
• ...and more
![Page 34: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/34.jpg)
Build Pipeline
![Page 35: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/35.jpg)
What's Missing?
• JUnit output from serverspec
• View most recent run of all pipelines
• Notifications
![Page 36: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/36.jpg)
Not the whole story...
• Testing a set of cookbooks
• Testing multiple nodes
• Promoting releases
![Page 37: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/37.jpg)
Summary
• Not that hard to get started
• Immediately valuable
• Share your work!
![Page 38: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/38.jpg)
Questions?
![Page 39: CLUG 2014-10 - Cookbook CI with Jenkins](https://reader036.vdocuments.site/reader036/viewer/2022062406/558d159fd8b42a77248b461a/html5/thumbnails/39.jpg)
Resources
http://www.cryptocracy.com/blog/2014/01/03/cooking-with-jenkins-test-kitchen-and-docker/https://erichelgeson.github.io/blog/2014/05/10/automating-your-automation-federated-jenkins-with-chef/http://atomic-penguin.github.io/blog/2014/05/16/stupid-jenkins-tricks-part-2-cookbook-pipelines/http://www.hurryupandwait.io/blog/using-git-to-version-stamp-chef-artifacts
https://github.com/jenkinsci/job-dsl-plugin/wikihttps://wiki.jenkins-ci.org/display/JENKINS/Build+Pipeline+Pluginhttps://wiki.jenkins-ci.org/display/JENKINS/Building+a+matrix+project