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:
parent
4ce4fc209d
commit
438a5c603c
55
modules/jenkins/manifests/plugin.pp
Normal file
55
modules/jenkins/manifests/plugin.pp
Normal 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'],
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user