Skip to content
Zhelyan edited this page Feb 14, 2016 · 10 revisions

The story in pictures

Authenticate with the Chef server.

You can create multiple credentials if you wish.

- Configure the Chef API from a knife/client .rb file.

This should be an admin client! The .rb/.pem files can be deleted later.

image

- Confirm the auth succeeded

image

Configure your job.

- Add a new Build parameter - 'List Chef environments'.

Note that you can replace this with any build parameter or env variable as long as you reference it in the build wrapper (see below)

image

- Add a build parameters or env variable for each artifact you want to deploy.

Here's an example using build parameters

image

- Add new Build wrapper - 'Save details to data bag item'.

The wrapper needs to know which environment you are deploying to, which packages and where you want to save this information (in which Chef data bag item)

image

- Add a new build step which runs chef-client on the servers.

You can skip this step if you don't require immediate deployment. Given that the chef-client service is running on your servers it will eventually deploy the changes.

For immediate deployment you can do something like:

knife ssh "chef_environment:$ENV AND role:myapp" 'sudo chef-client'

or knife ssh -m '10.10.1.2 10.10.2.3 $ENV.myapp.mycompany.com' 'sudo chef-client'

Run the job.

If you have parameterized the build and if you used the 'List Chef environments' parameter the plugin will retrieve the environments from the Chef server

image

The selected data bag item will be updated:

image

The plugin will generate links to an environment report page where you can track what got deployed where

This is available for both the project and for individual builds:

image

Environment report page

image