Skip to content

A jenkins library to test and publish cookbooks with jenkins containers

Notifications You must be signed in to change notification settings

mtyler/jenkins-cookbook-pipeline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jenkins-cookbook-pipeline

A proof-of-concept, multi-purpose repo for testing and publishing cookbooks using Jenkins Docker containers.

In current form, this is best suited for creating a quick and dirty, on-the-fly, cookbook pipeline and works nicely as an ephemeral pipeline for local development. Careful considerations should be made before porting any of this functionality to a production environment.

What this does:

  1. creates a fresh jenkins install with a blueocean container
  2. installs plugins, configures and turns off the install wizard
  3. creates Admin user
  4. integrates with github repo and pulls/runs Jenkinsfile from a given cookbook repo
  5. creates a jenkins builder container (inside master) to run pipeline
  6. runs .kitchen.docker.yml (inside builder)
  7. runs cookbook validations and publishes the master branch to a Chef Server on Host network
  8. continues watching repo until destroyed

alt text

Known Issues

  • The setup_jenkins.sh file is heavily dependent on static environment variables.
  • keys and configurations need to added to jenkins-master dir.

Jenkins Master setup files

  • ./jenkins-master/*

Usage

  1. Add these files to the jenkins-master directory. This is the Jenkins Master Docker build context and the following files are used to build the container
  • jenkins-master/cicdsvc-knife.rb A knife configuration file with the appropriate configuration for your environment
  • jenkins-master/cicdsvc.pem A client.pem key for the user specified in the knife.rb file
  • create jenkins-master/github-token file containing a valid github token A Github Access Token with repo and user email access to the cookbook repo
  1. Edit setup_jenkins.sh and set Environment variables appropriately

  2. Run ./jenkins-master/setup_jenkins.sh

Jenkins Library

This will run the bare bones basics of a cookbook pipeline.

  • Unit tests with chefspec
  • Linting with foodcritic and cookstyle
  • Functional tests with TestKitchen
  • Publishing to a Chef Server

Library files

  • ./vars/publishMaster.groovy
  • ./resources/Dockerfile (Jenkins Builder) A Dockerfile for running a cookbook builder inside the jenkinsci/blueocean Jenkins container

Usage

A bundle of bash hackery to setup Chef infrastructure with a cookbook pipeline.

A Jenkinsfile that dynamically imports the pipeline library.

// Dynamically include a jenkins library
library identifier: 'jenkins-cookbook-pipeline@master', retriever: modernSCM(
  [$class: 'GitSCMSource',
   remote: 'git://github.com/mtyler/jenkins-cookbook-pipeline.git'])

// Call groovy method containing shared pipeline.
// Argument should be the name of the cookbook
node {
  publishMaster 'chef-infra-base'
}

More Jenkins Cookbook Libraries

This library by James Massardo is more robust and provides more functionality. Especially, if you are coordinating between OS & Apps teams and multiple BUs. https://github.com/jmassardo/Chef-Jenkins-Library

About

A jenkins library to test and publish cookbooks with jenkins containers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published