File tree 2 files changed +30
-0
lines changed
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 11
11
# path to a puppet file() resource containing the Jenkins XML job description
12
12
# will override 'config' if set
13
13
#
14
+ # template
15
+ # path to a puppet template() resource containing the Jenkins XML job description
16
+ # will override 'config' if set
17
+ #
14
18
# jobname = $title
15
19
# the name of the jenkins job
16
20
#
23
27
define jenkins::job (
24
28
$config ,
25
29
$source = undef ,
30
+ $template = undef ,
26
31
$jobname = $title,
27
32
$enabled = 1,
28
33
$ensure = ' present' ,
42
47
validate_string($source )
43
48
$realconfig = file ($source )
44
49
}
50
+ elsif $template {
51
+ validate_string($template )
52
+ $realconfig = template ($template )
53
+ }
45
54
else {
46
55
$realconfig = $config
47
56
}
Original file line number Diff line number Diff line change 127
127
it { should raise_error ( Puppet ::Error , /Must pass config/ ) }
128
128
end
129
129
130
+ describe 'with templated config and blank regular config' do
131
+ let ( :thetemplate ) { File . expand_path ( File . dirname ( __FILE__ ) + '/../fixtures/testjob.xml' ) }
132
+ let ( :params ) { { :ensure => 'present' , :template => thetemplate , :config => '' } }
133
+ it { should contain_file ( '/tmp/myjob-config.xml' ) \
134
+ . with_content ( /sourcedconfig/ ) }
135
+ end
136
+
137
+ describe 'with templated config and regular config' do
138
+ quotes = "<xml version='1.0' encoding='UTF-8'></xml>"
139
+ let ( :thetemplate ) { File . expand_path ( File . dirname ( __FILE__ ) + '/../fixtures/testjob.xml' ) }
140
+ let ( :params ) { { :ensure => 'present' , :template => thetemplate , :config => quotes } }
141
+ it { should contain_file ( '/tmp/myjob-config.xml' ) \
142
+ . with_content ( /sourcedconfig/ ) }
143
+ end
144
+
145
+ describe 'with templated config and no regular config' do
146
+ let ( :thetemplate ) { File . expand_path ( File . dirname ( __FILE__ ) + '/../fixtures/testjob.xml' ) }
147
+ let ( :params ) { { :ensure => 'present' , :template => thetemplate } }
148
+ it { should raise_error ( Puppet ::Error , /Must pass config/ ) }
149
+ end
150
+
130
151
end
You can’t perform that action at this time.
0 commit comments