Skip to content

Instantly share code, notes, and snippets.

@kannan4k
Created December 2, 2015 10:22
Show Gist options
  • Save kannan4k/e5fb7fb8b56d509dd7be to your computer and use it in GitHub Desktop.
Save kannan4k/e5fb7fb8b56d509dd7be to your computer and use it in GitHub Desktop.
Jenkins Jobs Automation
"jenkins": {
"jobs": {
"Test Chef integration - production stack": {
"description": "Production version of web stack",
"variable1": "value1",
"variable2": "value2",
"variable3": "value3",
},
"Test jenkins job": {
"description": "Development version of web stack",
"variable4": "value4",
"variable5": "value5",
"variable6": "value6",
}
}
}
@kannan4k
Copy link
Author

kannan4k commented Dec 2, 2015

node['jenkins']['jobs'].each do |job_name, jobs_details|
    jobs_details.each do 

        template job_config_xml do
            source "sample.xml.erb"
            variables 
# this is just a idea
                job_details.each do |attribute_name, attribute_value|
                     :attribute_name => attribute_value
# which should transforms to 
                 :description => jobs_details['description'],
                 :variable1 => value1,
                 :variable2 => value2
#end
            notifies :create, resources(:jenkins_job => job_name), :immediately
        end
    end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment