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
This commit is contained in:
Dan Bode 2013-07-31 17:43:53 -07:00 committed by James E. Blair
parent 4ce4fc209d
commit 438a5c603c

View File

@ -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'],
}
}