jenkins_pipeline_builder 0.12.0 → 0.12.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTI4NWI4YWJjMDk4MzJiNzgzMTAwZWJhYzE0ZDJmYTQzYWFlZDEyYw==
4
+ NTE5YjExNDk4YWIyNzM4OWZkYTI2MWEyNWZjODFmODk4YmJhMDA0OA==
5
5
  data.tar.gz: !binary |-
6
- YmJiMGY3NzU0ODEwY2ZkMzUyZGZjOTQzZTlmZGRkMTRiMzVkMDIxMg==
6
+ MDVmZWJiZDg0Yzk1ODYxYzU5NDlmMjJkYTRhODM0NTU5YzgyMDBjYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTVjYmM2M2E4MjZiM2RjNTQ3OTIyZTdlMTgxOTE3MGMzZGQyZmQ4M2VlNTgz
10
- YTVmZmQxZGFjZjU0YmZjNDYxM2Q4MWI0ZTlmZmYxZGQ0YTBkOGVkMGEzYzMz
11
- YTY4ZjM2OTVmMDI2NWNlMzc4ZTZiNTE0M2JhM2E4ZDY1MGFhYmI=
9
+ NDU1MzcyYWQzNjg3ZjFiODcwNWQzNzg4N2U1ZTgyNjBhNjc3MTdlZTk5ZDky
10
+ MWYxYTM2MjRhMjQ5MDE3Nzc2YWZiYTJmOTAyOWVkYzFiN2I2YzI1OTJlNzMw
11
+ NDg0NzBhZGU0ZTRjNDgxZTJkZjA0ZjZmNmQ2NDdlYmM2Y2IwZTM=
12
12
  data.tar.gz: !binary |-
13
- ZWM5MzhiOGU2MGY5NWMzZGU4NGVjYTc3NzdhYjlhNzEzZDNjN2Q2YTg3NTVk
14
- YzYxYjgwZDJkMzY1YTgxODk0Y2M5ZmVhOGUyZWNmZGE4NzBiMmNlYmE3ZmFk
15
- NDIyMzY0NDU1ZTJjNzRhYzVjMTEyMWU2Y2U3MzkxYzlhMjQ1Y2Y=
13
+ OTViNzJiYzI5OTk3ZWQ0MzhhMzk4M2I2ZmMwMTMxMWE1NDllODFmZDUxYzY4
14
+ MGFkMWY0MzM1YmY0ZGQzYzJhYjQxMDRkN2MxY2ViMTk0ZDdiNWU3MDg3MjAx
15
+ NmNmNDg2Y2E2N2QyZjQ1OTQwODM4ZDFmYTVjOTcyNTIzNDA3NGU=
@@ -297,6 +297,36 @@ builder do
297
297
  end
298
298
  end
299
299
 
300
+ builder do
301
+ name :system_groovy
302
+ plugin_id 'groovy'
303
+ description 'Lets you run groovy scripts as a build step.'
304
+ jenkins_name 'System Groovy'
305
+ announced false
306
+
307
+ xml do |params|
308
+ send('hudson.plugins.groovy.SystemGroovy', 'plugin' => 'groovy@1.24') do
309
+ if params.key?(:script) && params.key?(:file)
310
+ fail 'Configuration invalid. Both \'script\' and \'file\' keys can not be specified'
311
+ end
312
+ unless params.key?(:script) || params.key?(:file)
313
+ fail 'Configuration invalid. At least one of \'script\' and \'file\' keys must be specified'
314
+ end
315
+
316
+ scriptSource('class' => 'hudson.plugins.groovy.StringScriptSource') do
317
+ command params[:script]
318
+ end if params.key? :script
319
+
320
+ scriptSource('class' => 'hudson.plugins.groovy.FileScriptSource') do
321
+ scriptFile params[:file]
322
+ end if params.key? :file
323
+
324
+ bindings params[:bindings]
325
+ classpath params[:classpath]
326
+ end
327
+ end
328
+ end
329
+
300
330
  builder do
301
331
  name :checkmarx_scan
302
332
  plugin_id 'checkmarx'
@@ -36,6 +36,18 @@ job_attribute do
36
36
  end
37
37
  end
38
38
 
39
+ job_attribute do
40
+ name :jdk
41
+ plugin_id 'builtin'
42
+ description 'This is the jdk used in the job.'
43
+ jenkins_name 'JDK'
44
+ announced false
45
+
46
+ xml path: '//project' do |jdk|
47
+ jdk "#{jdk}"
48
+ end
49
+ end
50
+
39
51
  job_attribute do
40
52
  name :disabled
41
53
  plugin_id 'builtin'
@@ -21,5 +21,5 @@
21
21
  #
22
22
 
23
23
  module JenkinsPipelineBuilder
24
- VERSION = '0.12.0'
24
+ VERSION = '0.12.1'
25
25
  end
@@ -137,4 +137,74 @@ describe 'builders' do
137
137
  end
138
138
  end
139
139
  end
140
+
141
+ context 'system_groovy' do
142
+ error = ''
143
+ before :each do
144
+ error = ''
145
+ allow(JenkinsPipelineBuilder.client).to receive(:plugin).and_return double(
146
+ list_installed: { 'groovy' => '1.24' })
147
+
148
+ begin
149
+ JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
150
+ rescue RuntimeError => boom
151
+ puts "Caught error #{boom}"
152
+ error = boom.to_s
153
+ end
154
+ builder = @n_xml.root.children.first
155
+ expect(builder.name).to match 'hudson.plugins.groovy.SystemGroovy'
156
+ end
157
+
158
+ context 'script given as string' do
159
+ let(:params) { { builders: { system_groovy: { script: 'print "Hello world"' } } } }
160
+
161
+ it 'generates a configuration' do
162
+ node = @n_xml.xpath '//hudson.plugins.groovy.SystemGroovy/scriptSource/command'
163
+ expect(node.children.first.content).to eq 'print "Hello world"'
164
+ end
165
+ end
166
+
167
+ context 'script given as file' do
168
+ let(:params) { { builders: { system_groovy: { file: 'myScript.groovy' } } } }
169
+
170
+ it 'generates a configuration' do
171
+ node = @n_xml.xpath '//hudson.plugins.groovy.SystemGroovy/scriptSource/scriptFile'
172
+ expect(node.children.first.content).to eq 'myScript.groovy'
173
+ end
174
+ end
175
+
176
+ context 'bindings' do
177
+ let(:params) { { builders: { system_groovy: { file: 'myScript.groovy', bindings: 'myVar=foo' } } } }
178
+
179
+ it 'generates a configuration' do
180
+ node = @n_xml.xpath '//hudson.plugins.groovy.SystemGroovy/bindings'
181
+ expect(node.children.first.content).to eq 'myVar=foo'
182
+ end
183
+ end
184
+
185
+ context 'classpath' do
186
+ let(:params) { { builders: { system_groovy: { file: 'myScript.groovy', classpath: '/tmp/myJar.jar' } } } }
187
+
188
+ it 'generates a configuration' do
189
+ node = @n_xml.xpath '//hudson.plugins.groovy.SystemGroovy/classpath'
190
+ expect(node.children.first.content).to eq '/tmp/myJar.jar'
191
+ end
192
+ end
193
+
194
+ context 'both script and file specified' do
195
+ let(:params) { { builders: { system_groovy: { file: 'myScript.groovy', script: 'print "Hello world"' } } } }
196
+
197
+ it 'fails' do
198
+ expect(error).to eq 'Configuration invalid. Both \'script\' and \'file\' keys can not be specified'
199
+ end
200
+ end
201
+
202
+ context 'neither script and file specified' do
203
+ let(:params) { { builders: { system_groovy: {} } } }
204
+
205
+ it 'fails' do
206
+ expect(error).to eq 'Configuration invalid. At least one of \'script\' and \'file\' keys must be specified'
207
+ end
208
+ end
209
+ end
140
210
  end
@@ -123,6 +123,20 @@ describe 'job_attributes' do
123
123
  end
124
124
  end
125
125
 
126
+ context 'jdk' do
127
+ it 'sets jdk' do
128
+ params = { jdk: 'JDK-8u45' }
129
+
130
+ builder = Nokogiri::XML::Builder.new do |xml|
131
+ xml.project
132
+ end
133
+ @n_xml = builder.doc
134
+
135
+ JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
136
+ expect(@n_xml.root.css('jdk').first.content).to eq 'JDK-8u45'
137
+ end
138
+ end
139
+
126
140
  context 'scm params' do
127
141
  before :each do
128
142
  builder = Nokogiri::XML::Builder.new { |xml| xml.scm }
@@ -39,7 +39,8 @@ BUILDERS = {
39
39
  multi_job: ['0'],
40
40
  remote_job: ['0'],
41
41
  shell_command: ['0'],
42
- checkmarx_scan: ['0']
42
+ checkmarx_scan: ['0'],
43
+ system_groovy: ['0']
43
44
  }
44
45
  TRIGGERS = {
45
46
  git_push: ['0'],
@@ -50,6 +51,7 @@ TRIGGERS = {
50
51
  JOB_ATTRIBUTES = {
51
52
  concurrent_build: ['0'],
52
53
  description: ['0'],
54
+ jdk: ['0'],
53
55
  disabled: ['0'],
54
56
  discard_old: ['0'],
55
57
  hipchat: ['0'],
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jenkins_pipeline_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Moochnick
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-25 00:00:00.000000000 Z
12
+ date: 2015-06-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri