jenkins_pipeline_builder 0.16.0 → 0.16.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2435d7d3bfbce44945a8ac65b3a2e974447659aa
4
- data.tar.gz: 91f22ff5ea5254f056d3ebbd2966b2ddb1a968d2
3
+ metadata.gz: 0e6d66b2aeb97ff13d1857f917d40823f04a0475
4
+ data.tar.gz: c65360bb36f9b0b75c726d069672dbfdd701887d
5
5
  SHA512:
6
- metadata.gz: e3eaad5a500bbe56cfd70dac4d56ee3834d041e935b984386432b0d84e7eacc2db8541348f79d19e083a0e412089232d36cc5400d7f646e00a6eda8cbfb90936
7
- data.tar.gz: 8b55b43d229e060aca4165941242acdbaca512ad3b645314c76a13ac780496ee65312952fcf2aab456fbe46cfb4def734f41eed798efe7fc6bba4e5c30e56acb
6
+ metadata.gz: 4cfefd6a9a7955b33858657599a9899d91c32b304d631f86f184c7f90321409754d182eda1bf8ee11209fc448067d7c51b10cc6a3cd6420f664a03d06f4bdc27
7
+ data.tar.gz: 5221d04269f542077e959f047f01f0062767d0a9f8e3b3f8a1be145760063b430f6b78d2786fba06c9232b8497e14381f8144448de172767bcab216c4cbad07b
@@ -377,31 +377,79 @@ builder do
377
377
  filterPattern params[:filterPattern]
378
378
  end
379
379
  end
380
+ end
381
+
382
+ builder do
383
+ name :sonar_standalone
384
+ plugin_id 'sonar'
385
+ description 'The plugin allows you to trigger SonarQube analysis from Jenkins using a Post-build action to trigger the analysis with MavenQuickly benefit from Sonar, the open source platform for Continuous Inspection of code quality.'
386
+ jenkins_name 'SonarQube Plugin'
387
+ announced false
388
+ parameters [
389
+ :sonarInstallation,
390
+ :taskToRun,
391
+ :jdk,
392
+ :pathToProjectProperties,
393
+ :projectProperties,
394
+ :jvmOptions
395
+ ]
380
396
 
381
- builder do
382
- name :sonar_standalone
383
- plugin_id 'sonar'
384
- description 'Quickly benefit from Sonar, the open source platform for Continuous Inspection of code quality.'
385
- jenkins_name 'SonarQube Plugin'
386
- announced false
387
- parameters [
388
- :sonarInstallation,
389
- :taskToRun,
390
- :jdk,
391
- :pathToProjectProperties,
392
- :projectProperties,
393
- :jvmOptions
394
- ]
397
+ xml do |params|
398
+ send('hudson.plugins.sonar.SonarRunnerBuilder', 'plugin' => 'sonar@2.1') do
399
+ installationName params[:sonarInstallation]
400
+ jdk params[:jdk] || '(Inherit From Job)'
401
+ project params[:pathToProjectProperties]
402
+ properties params[:projectProperties]
403
+ javaOpts params[:jvmOptions]
404
+ task params[:taskToRun]
405
+ end
406
+ end
407
+ end
395
408
 
396
- xml do |params|
397
- send('hudson.plugins.sonar.SonarRunnerBuilder', 'plugin' => 'sonar@2.1') do
398
- installationName params[:sonarInstallation]
399
- project params[:pathToProjectProperties]
400
- properties params[:projectProperties]
401
- javaOpts params[:jvmOptions]
402
- jdk params[:jdk]
403
- task params[:taskToRun]
409
+ builder do
410
+ name :conditional_multijob_step
411
+ plugin_id 'conditional-buildstep'
412
+ description 'description'
413
+ jenkins_name 'Conditional Build Step'
414
+ announced false
415
+
416
+ xml do |params|
417
+ send('org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder', 'plugin' => 'conditional-buildstep@1.3.3') do
418
+ condition('class' => 'org.jenkins_ci.plugins.run_condition.contributed.ShellCondition', 'plugin' => 'run-condition@1.0') do
419
+ command params[:conditional_shell]
420
+ end
421
+ params[:phases].each do |name, content|
422
+ buildStep('class' => 'com.tikal.jenkins.plugins.multijob.MultiJobBuilder', 'plugin' => 'jenkins-multijob-plugin@1.13') do
423
+ phaseName name
424
+ phaseJobs do
425
+ content[:jobs].each do |job|
426
+ send('com.tikal.jenkins.plugins.multijob.PhaseJobsConfig') do
427
+ jobName job[:name]
428
+ currParams job[:current_params] || false
429
+ exposedSCM job[:exposed_scm] || false
430
+ if job[:config]
431
+ configs do
432
+ if job[:config].key? :predefined_build_parameters
433
+ send('hudson.plugins.parameterizedtrigger.PredefinedBuildParameters') do
434
+ properties job[:config][:predefined_build_parameters]
435
+ end
436
+ end
437
+ if job[:config].key? :properties_file
438
+ send('hudson.plugins.parameterizedtrigger.FileBuildParameters') do
439
+ propertiesFile job[:config][:properties_file][:file]
440
+ failTriggerOnMissing job[:config][:properties_file][:skip_if_missing] || 'false'
441
+ end
442
+ end
443
+ end
444
+ end
445
+ killPhaseOnJobResultCondition job[:kill_phase_on] || 'FAILURE'
446
+ end
447
+ end
448
+ end
449
+ continuationCondition content[:continue_condition] || 'SUCCESSFUL'
450
+ end
404
451
  end
452
+ runner('class' => 'org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail', 'plugin' => 'run-condition@1.0')
405
453
  end
406
454
  end
407
455
  end
@@ -21,5 +21,5 @@
21
21
  #
22
22
 
23
23
  module JenkinsPipelineBuilder
24
- VERSION = '0.16.0'.freeze
24
+ VERSION = '0.16.2'.freeze
25
25
  end
@@ -100,6 +100,33 @@ describe 'builders' do
100
100
  end
101
101
  end
102
102
 
103
+ context 'sonar_standalone' do
104
+ before :each do
105
+ allow(JenkinsPipelineBuilder.client).to receive(:plugin).and_return double(
106
+ list_installed: { 'sonar' => '2.1' }
107
+ )
108
+ end
109
+
110
+ it 'generates a configuration' do
111
+ params = { builders: { sonar_standalone: { pathToProjectProperties: 'sonar-project.properties' } } }
112
+
113
+ JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
114
+
115
+ builder = @n_xml.root.children.first
116
+ expect(builder.name).to match 'hudson.plugins.sonar.SonarRunnerBuilder'
117
+ expect(@n_xml.root.css('project').first.text).to eq 'sonar-project.properties'
118
+ expect(@n_xml.root.css('jdk').first.text).to eq '(Inherit From Job)'
119
+ end
120
+
121
+ it 'allows the JDK default to be overriden' do
122
+ params = { builders: { sonar_standalone: { jdk: '9', pathToProjectProperties: 'sonar-project.properties' } } }
123
+
124
+ JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
125
+
126
+ expect(@n_xml.root.css('jdk').first.text).to eq '9'
127
+ end
128
+ end
129
+
103
130
  context 'blocking_downstream' do
104
131
  before :each do
105
132
  allow(JenkinsPipelineBuilder.client).to receive(:plugin).and_return double(
@@ -209,4 +236,80 @@ describe 'builders' do
209
236
  end
210
237
  end
211
238
  end
239
+
240
+ context 'conditional_multijob_step' do
241
+ let(:default_params) do
242
+ {
243
+ builders: {
244
+ conditional_multijob_step: {
245
+ conditional_shell: 'echo',
246
+ phases: {
247
+ myphase1: {
248
+ jobs: [
249
+ {
250
+ name: 'myjob1',
251
+ config: {
252
+ predefined_build_parameters: 'X=Y\nR=Z'
253
+ }
254
+ }
255
+ ]
256
+ }
257
+ }
258
+ }
259
+ }
260
+ }
261
+ end
262
+ let(:base_x_path) do
263
+ '//org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder'
264
+ end
265
+ let(:build_step_x_path) do
266
+ "#{base_x_path}/buildStep"
267
+ end
268
+ let(:phase_jobs_x_path) do
269
+ "#{build_step_x_path}/phaseJobs/com.tikal.jenkins.plugins.multijob.PhaseJobsConfig"
270
+ end
271
+
272
+ before :each do
273
+ allow(JenkinsPipelineBuilder.client).to receive(:plugin).and_return double(
274
+ list_installed: { 'conditional-buildstep' => '1.3.3' }
275
+ )
276
+ end
277
+
278
+ it 'generates a configuration' do
279
+ params = default_params
280
+ JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
281
+ builder = @n_xml.root.children.first
282
+ expect(builder.name).to match 'org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder'
283
+ command = @n_xml.xpath base_x_path
284
+ expect(command.first.content).to match 'echo'
285
+ end
286
+
287
+ it 'creates a phase' do
288
+ params = default_params
289
+ JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
290
+ phase_name = @n_xml.xpath "#{build_step_x_path}/phaseName"
291
+ expect(phase_name.first.content).to match 'myphase1'
292
+ phase_continue = @n_xml.xpath "#{build_step_x_path}/continuationCondition"
293
+ expect(phase_continue.first.content).to match 'SUCCESSFUL'
294
+ end
295
+
296
+ it 'creates a job' do
297
+ params = default_params
298
+
299
+ JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
300
+ job_name = @n_xml.xpath "#{phase_jobs_x_path}/jobName"
301
+ expect(job_name.first.content).to match 'myjob1'
302
+ curr_params = @n_xml.xpath "#{phase_jobs_x_path}/currParams"
303
+ expect(curr_params.first.content).to match 'false'
304
+ exposed_scm = @n_xml.xpath "#{phase_jobs_x_path}/exposedSCM"
305
+ expect(exposed_scm.first.content).to match 'false'
306
+ predefined_params = @n_xml.xpath "#{phase_jobs_x_path}/"\
307
+ 'configs/hudson.plugins.parameterizedtrigger.PredefinedBuildParameters'
308
+ expect(predefined_params.first.content).to match 'X=Y\nR=Z'
309
+ kill_phase_cond = @n_xml.xpath "#{phase_jobs_x_path}/killPhaseOnJobResultCondition"
310
+ expect(kill_phase_cond.first.content).to match 'FAILURE'
311
+ end
312
+
313
+ # TODO: More tests
314
+ end
212
315
  end
@@ -43,7 +43,8 @@ BUILDERS = {
43
43
  shell_command: ['0'],
44
44
  checkmarx_scan: ['0'],
45
45
  system_groovy: ['0'],
46
- sonar_standalone: ['0']
46
+ sonar_standalone: ['0'],
47
+ conditional_multijob_step: ['0']
47
48
  }.freeze
48
49
 
49
50
  TRIGGERS = {
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.16.0
4
+ version: 0.16.2
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: 2016-10-31 00:00:00.000000000 Z
12
+ date: 2016-11-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri