forked from voxpupuli/puppet-jenkins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli_helper.pp
59 lines (52 loc) · 1.49 KB
/
cli_helper.pp
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Class jenkins::cli_helper
#
# A helper script for creating resources via the Jenkins cli
#
# Parameters:
#
# ssh_keyfile = undef
# Defaults to the value of $::jenkins::cli_ssh_keyfile. This parameter is
# deprecated, please set $::jenkins::cli_ssh_keyfile instead of setting this
# directly
#
class jenkins::cli_helper (
$ssh_keyfile = $::jenkins::cli_ssh_keyfile,
) {
include ::jenkins
include ::jenkins::cli
if $ssh_keyfile { validate_absolute_path($ssh_keyfile) }
Class['jenkins::cli'] ->
Class['jenkins::cli_helper'] ->
Anchor['jenkins::end']
$libdir = $::jenkins::libdir
$cli_jar = $::jenkins::cli::jar
$port = jenkins_port()
$prefix = jenkins_prefix()
$helper_groovy = "${libdir}/puppet_helper.groovy"
file { $helper_groovy:
source => 'puppet:///modules/jenkins/puppet_helper.groovy',
owner => $::jenkins::user,
group => $::jenkins::group,
mode => '0444',
require => Class['jenkins::cli'],
}
# Provide the -i flag if specified by the user.
if $ssh_keyfile {
$auth_arg = "-i ${ssh_keyfile}"
} else {
$auth_arg = undef
}
if $ssh_keyfile != $::jenkins::cli_ssh_keyfile {
info("Using jenkins::cli_helper(${ssh_keyfile}) is deprecated and will be removed in the next major version of this module")
}
$helper_cmd = join(
delete_undef_values([
'/usr/bin/java',
"-jar ${::jenkins::cli::jar}",
"-s http://127.0.0.1:${port}${prefix}",
$auth_arg,
"groovy ${helper_groovy}",
]),
' '
)
}