forked from voxpupuli/puppet-jenkins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjob.pp
78 lines (73 loc) · 1.83 KB
/
job.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Define: jenkins::job
#
# This class create a new jenkins job given a name and config xml
#
# Parameters:
#
# config
# the content of the jenkins job config file (required)
#
# source
# path to a puppet file() resource containing the Jenkins XML job description
# will override 'config' if set
#
# template
# path to a puppet template() resource containing the Jenkins XML job description
# will override 'config' if set
#
# jobname = $title
# the name of the jenkins job
#
# enabled
# deprecated parameter (will have no effect if set)
#
# ensure = 'present'
# choose 'absent' to ensure the job is removed
#
# difftool = '/usr/bin/diff -b-q'
# Provide a command to execute to compare Jenkins job files
#
define jenkins::job(
$config,
$source = undef,
$template = undef,
$jobname = $title,
$enabled = undef,
$ensure = 'present',
$difftool = '/usr/bin/diff -b -q',
){
validate_string($config)
if $source { validate_absolute_path($source) }
if $template { validate_absolute_path($template) }
validate_string($jobname)
if $enabled != undef {
warning("You set \$enabled to ${enabled}, this parameter is now deprecated, nothing will change whatever is its value")
}
validate_re($ensure, '^present$|^absent$')
validate_string($difftool)
include ::jenkins::cli
Class['jenkins::cli'] ->
Jenkins::Job[$title] ->
Anchor['jenkins::end']
if ($ensure == 'absent') {
jenkins::job::absent { $title:
jobname => $jobname,
}
} else {
if $source {
$realconfig = file($source)
}
elsif $template {
$realconfig = template($template)
}
else {
$realconfig = $config
}
jenkins::job::present { $title:
config => $realconfig,
jobname => $jobname,
enabled => $enabled,
difftool => $difftool,
}
}
}