summaryrefslogtreecommitdiffstats
path: root/puppet/modules/jenkins_server/manifests/zip_plugin.pp
blob: 92bf85f36d873f723b0af68bf7541b43021e3656 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Unzip and installs a Jenkins plugin.
# Doesn't automatically restart Jenkins to load the plugin, so the plugin won't appear
# until the next restart.
#
define jenkins_server::zip_plugin(
    $url = undef
) {

    $plugins_dir = "/var/lib/jenkins/plugins"

    # note: although the URL above uses .hpi (hudson plug-in) as the file extension,
    # the Jenkins plugin center renames .hpi to .jpi when installing, so we will do the same
    # for compatibility.
    $filename = "$plugins_dir/$name.jpi"

    exec { "install jenkins plugin $url -> $filename":
        command =>
            "/bin/su -c '\
                \
                wget -q -O $name.zip.downloading $url && \
                unzip $name.zip.downloading && rm $name.zip.downloading && \
                mv $name/$name.hpi $filename \
                \
            ' - jenkins"
        ,
        require => [
            File[$plugins_dir],
            Package["jenkins"],
        ],
        creates => $filename,
        logoutput => true,
    }
}