1

using the jenkins cookbook 2.2.2

==> https://supermarket.chef.io/cookbooks/jenkins

i can bring up jenkins in vagrant vm using chef_zero provisioner with

chef.run_list = [ 'recipe[jenkins::master]', ]

however, i am trying to install plugins and create a new job from erb template, and i am having no luck. my understanding is that configuration should be passed using the "chef.json" datastructure with chef zero. I have tried many many syntax configurations, but no luck (and no error, as it appears if not correct, it is just ignored)

here is an example of installing a plugin that is not working (i guess the question is how does one configure a chef resource within a recipe inside of vagrant with chef_zero provision):

chef.json = { 'java' => { 'jdk_version' => '7', }, 'jenkins' => { 'master' => { 'jenkins_plugin' => [ 'job-dsl', 'groovy', 'git', 'packer' ] } } }

i would be very grateful if anyone could provide a working example of the chef.json that vagrant chef_zero provisioner wants to install jenkins plugin (and/or installing a new job from erb template or xml file)

1

the answer is plugins and jobs cannot be directly invoked by the community jenkins cookbook. a wrapper cookbook needs to be made (which depends on jenkins).

this is done by creating a blank cookbook: knife cookbook create jenkins_wrapper

adding community cookbook dependancy (jenkins_wrapper/metadata.rb): depends 'jenkins'

and then making it do something (jenkins_wrapper/recipes/default.rb): jenkins_plugin 'git' jenkins_plugin 'job-dsl'

additionally, if using berkshelf, you must add path to cookbook in Berksfile: cookbook 'jenkins_wrapper', path: '/path/to/jenkins_wrapper' (this path can be relative)

it took me a few hours to figure this all out, so hopefully this will help someone else save some time

0

You can give a look at this. Maybe it could be helpful

1
  • 1
    Welcome to ServerFault! While the article you link to may well be helpful, you should try to avoid posting link-only answers; try to include the useful content in your answer such that it does not rely solely on the link itself.
    – BE77Y
    May 18 '15 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.