VS.Mahesh
VS.Mahesh

Reputation: 21

Jenkins Plugin installation with chef cookbook

I got a task to create a (chef) cookbook that should install jenkins plugins.

Note: when i apply the cookbook it should install it automatically.

Thanks in advance.

Upvotes: 0

Views: 874

Answers (2)

StephenKing
StephenKing

Reputation: 37630

There is a jenkins cookbook that does this very well (look at the "jenkins_plugin" section)

Upvotes: 2

J0991
J0991

Reputation: 987

The Chef public Supermarket cookbook can be found here. If I was you, I would use that as the base for the functionality you require.

  1. Create a new cookbook which depends on the public Jenkins cookbook (this will cause your new cookbook to inherit all functionality found in the public cookbook).
  2. Create a new recipe in your new cookbook which specifies which plugins to be installed when Jenkins is installed / configured. See the Jenkins_Job section of the Chef Supermarket Jenkins cookbook for additional details.

Note: In order to find the correct .HPI file location for the version of the plugin you want to download, you can look at the Jenkins Wiki page for each plugin, and using the link to the archives of all releases of that plugin find a suitable link for the version you wish to install.

An additional step that I personally take is to write some automated tests to run against the plugin installation / configuration using Chef's test-kitchen:

  1. What I do is find the filepath for the particular plugin you want to verify has been installed, and write a test confirming that the filepath exists.
  2. An additional test I also write for each plugin is to parse the pom.xml configuration file found within the directory in order to verify that the correct version has been installed (in the event the link to the specific release available on the Jenkins Wiki is giving you the incorrect version).

And last but not least; I strongly recommend you use Berkshelf to manage your cookbook dependencies. If you go this route, it will be critical that you create your own cookbook which depends on the public cookbook so as you are able to upgrade your public cookbooks using Berkshelf without issue.

If not, all your custom configuration for plugins you have added to your copy of the public supermarket cookbook will be overwritten when you upgrade your public cookbook to the newest version when it's released.

Best of luck and please post any additional questions here!

Upvotes: 1

Related Questions