From 438a5c603c032a6a770120577430b10362dea010 Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Wed, 31 Jul 2013 17:43:53 -0700 Subject: [PATCH] Add jenkins::plugin defined resource type This commit adds jenkins::plugin which can be used to install jenkins plugins. I used it to install gearman just today: jenkins::plugin { 'gearman-plugin': version => '0.0.3', } Note: this code is borrowed from: https://github.com/jenkinsci/puppet-jenkins/blob/master/manifests/plugin.pp which is apache licensed. Change-Id: Ifd3f6452839db990357f14665f14aa839ec2d0c5 --- modules/jenkins/manifests/plugin.pp | 55 +++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 modules/jenkins/manifests/plugin.pp diff --git a/modules/jenkins/manifests/plugin.pp b/modules/jenkins/manifests/plugin.pp new file mode 100644 index 0000000000..2143a5fcbb --- /dev/null +++ b/modules/jenkins/manifests/plugin.pp @@ -0,0 +1,55 @@ +# +# Defined resource type to install jenkins plugins. +# +# Borrowed from: https://github.com/jenkinsci/puppet-jenkins +# + +define jenkins::plugin( + $version=0, +) { + $plugin = "${name}.hpi" + $plugin_dir = '/var/lib/jenkins/plugins' + $plugin_parent_dir = '/var/lib/jenkins' + + if ($version != 0) { + $base_url = "http://updates.jenkins-ci.org/download/plugins/${name}/${version}" + } + else { + $base_url = 'http://updates.jenkins-ci.org/latest' + } + + if (!defined(File[$plugin_dir])) { + file { + [ + $plugin_parent_dir, + $plugin_dir, + ]: + ensure => directory, + owner => 'jenkins', + group => 'jenkins', + require => [Group['jenkins'], User['jenkins']], + } + } + + if (!defined(Group['jenkins'])) { + group { 'jenkins' : + ensure => present, + } + } + + if (!defined(User['jenkins'])) { + user { 'jenkins' : + ensure => present, + } + } + + exec { "download-${name}" : + command => "wget --no-check-certificate ${base_url}/${plugin}", + cwd => $plugin_dir, + require => File[$plugin_dir], + path => ['/usr/bin', '/usr/sbin',], + user => 'jenkins', + unless => "test -d ${plugin_dir}/${name}", + notify => Service['jenkins'], + } +}