jenkins_pipeline_builder 1.5.2 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +8 -0
  3. data/.rubocop_todo.yml +59 -0
  4. data/Rakefile +1 -1
  5. data/jenkins_pipeline_builder.gemspec +15 -15
  6. data/lib/jenkins_pipeline_builder/cli/helper.rb +4 -4
  7. data/lib/jenkins_pipeline_builder/compiler.rb +3 -5
  8. data/lib/jenkins_pipeline_builder/extension_set.rb +8 -8
  9. data/lib/jenkins_pipeline_builder/extensions.rb +6 -4
  10. data/lib/jenkins_pipeline_builder/extensions/build_steps.rb +16 -14
  11. data/lib/jenkins_pipeline_builder/extensions/builders.rb +50 -46
  12. data/lib/jenkins_pipeline_builder/extensions/job_attributes.rb +25 -25
  13. data/lib/jenkins_pipeline_builder/extensions/promotion_conditions.rb +7 -7
  14. data/lib/jenkins_pipeline_builder/extensions/publishers.rb +36 -24
  15. data/lib/jenkins_pipeline_builder/extensions/wrappers.rb +1 -1
  16. data/lib/jenkins_pipeline_builder/generator.rb +4 -5
  17. data/lib/jenkins_pipeline_builder/job.rb +2 -2
  18. data/lib/jenkins_pipeline_builder/job_collection.rb +6 -4
  19. data/lib/jenkins_pipeline_builder/pull_request_generator.rb +4 -2
  20. data/lib/jenkins_pipeline_builder/remote_dependencies.rb +1 -3
  21. data/lib/jenkins_pipeline_builder/version.rb +1 -1
  22. data/spec/lib/jenkins_pipeline_builder/cli/helper_spec.rb +5 -5
  23. data/spec/lib/jenkins_pipeline_builder/extension_set_spec.rb +1 -1
  24. data/spec/lib/jenkins_pipeline_builder/extensions/job_attributes_spec.rb +1 -1
  25. data/spec/lib/jenkins_pipeline_builder/extensions/registered_spec.rb +1 -0
  26. data/spec/lib/jenkins_pipeline_builder/extensions/wrappers_spec.rb +4 -0
  27. data/spec/lib/jenkins_pipeline_builder/generator_spec.rb +1 -1
  28. data/spec/lib/jenkins_pipeline_builder/module_registry_spec.rb +3 -3
  29. metadata +57 -56
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40dedb407466d4dbcdca1495e4b10b95dad3d027761eabf815980850f7d55d0c
4
- data.tar.gz: 013341f2abbff6d1ec00bf731b20bc615347ea7693afefc459662b2ad4da9c0d
3
+ metadata.gz: e4d433fdb4421e7ff066fd49444c45abe2d2b29df62228b95b9d0933b0dce7f6
4
+ data.tar.gz: 2586bd749811dd2848490e146b926e42c7332526282c53ff43c5f706ad49a8fc
5
5
  SHA512:
6
- metadata.gz: 5c1b776786e820aa08f386c3aa5658f3a6c4fca69f8b2457885fe8751e91f9d83b3e1329c1ba9c0cf23bca314e493de22c569ba48dabc89d043048aa073cde94
7
- data.tar.gz: 8dade49ffff55821f81e760d3f37315b3e3355b1a2d804451c810dbdfb978cd9f3e1044f65ec2d7da42eb3064789d747b274a3d4b8776de7248c382c148046e7
6
+ metadata.gz: 0969f829a1b73b76c1954ea323352f66d346b90b307705016d28d8b1a74987580f4baaea75dc2ba8f5c59b4e7c41039307c2a4b96019cc0a30c8ab51db861940
7
+ data.tar.gz: 6a02902dc545bdd9e2086503818b0cf9095edbe0964a290140bbe1bd718bb3c0748de2763d5b290f7af05927efafa9299418d1145e843fe1f81f78c9cb5f3302
@@ -1,3 +1,8 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.1.5
3
+
4
+ inherit_from: .rubocop_todo.yml
5
+
1
6
  #######
2
7
  # WIP These should all go back to defaults at some point
3
8
  Metrics/AbcSize:
@@ -33,3 +38,6 @@ Style/VariableName:
33
38
 
34
39
  Style/SymbolProc:
35
40
  IgnoredMethods: new
41
+
42
+ Style/FrozenStringLiteralComment:
43
+ Enabled: false
@@ -0,0 +1,59 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2017-12-13 09:51:35 -0500 using RuboCop version 0.52.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 6
10
+ Lint/UriEscapeUnescape:
11
+ Exclude:
12
+ - 'lib/jenkins_pipeline_builder/promotion.rb'
13
+
14
+ # Offense count: 1
15
+ Lint/Void:
16
+ Exclude:
17
+ - 'lib/jenkins_pipeline_builder.rb'
18
+
19
+ # Offense count: 132
20
+ # Configuration parameters: CountComments, ExcludedMethods.
21
+ Metrics/BlockLength:
22
+ Max: 420
23
+
24
+ # Offense count: 5
25
+ # Cop supports --auto-correct.
26
+ # Configuration parameters: AutoCorrect.
27
+ Performance/HashEachMethods:
28
+ Exclude:
29
+ - 'lib/jenkins_pipeline_builder/cli/list.rb'
30
+ - 'lib/jenkins_pipeline_builder/compiler.rb'
31
+ - 'lib/jenkins_pipeline_builder/extensions.rb'
32
+ - 'lib/jenkins_pipeline_builder/utils.rb'
33
+
34
+ # Offense count: 1
35
+ # Configuration parameters: MinBodyLength.
36
+ Style/GuardClause:
37
+ Exclude:
38
+ - 'lib/jenkins_pipeline_builder/pull_request_generator.rb'
39
+
40
+ # Offense count: 1
41
+ Style/MultipleComparison:
42
+ Exclude:
43
+ - 'lib/jenkins_pipeline_builder/extensions/publishers.rb'
44
+
45
+ # Offense count: 3
46
+ # Cop supports --auto-correct.
47
+ # Configuration parameters: AutoCorrect, EnforcedStyle.
48
+ # SupportedStyles: predicate, comparison
49
+ Style/NumericPredicate:
50
+ Exclude:
51
+ - 'spec/**/*'
52
+ - 'lib/jenkins_pipeline_builder/compiler.rb'
53
+ - 'lib/jenkins_pipeline_builder/module_registry.rb'
54
+ - 'lib/jenkins_pipeline_builder/remote_dependencies.rb'
55
+
56
+ Layout/EmptyLinesAroundArguments:
57
+ Exclude:
58
+ - 'lib/jenkins_pipeline_builder/extensions/triggers.rb'
59
+
data/Rakefile CHANGED
@@ -45,4 +45,4 @@ namespace :doc do
45
45
  end
46
46
  end
47
47
 
48
- task default: [:spec, :rubocop]
48
+ task default: %i[spec rubocop]
@@ -1,4 +1,4 @@
1
- # coding: utf-8
1
+
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'jenkins_pipeline_builder/version'
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = 'jenkins_pipeline_builder'
8
8
  spec.version = JenkinsPipelineBuilder::VERSION
9
9
  spec.authors = ['Igor Moochnick', 'Joseph Henrich']
10
- spec.email = %w(igor.moochnick@gmail.com crimsonknave@gmail.com)
10
+ spec.email = %w[igor.moochnick@gmail.com crimsonknave@gmail.com]
11
11
  spec.description = 'This is a simple and easy-to-use Jenkins Pipeline generator with features focused on
12
12
  automating Job & Pipeline creation from the YAML files checked-in with your application source code'
13
13
  spec.summary = 'This gem is will boostrap your Jenkins pipelines'
@@ -21,27 +21,27 @@ automating Job & Pipeline creation from the YAML files checked-in with your appl
21
21
 
22
22
  ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES'] = 'true'
23
23
 
24
- spec.add_dependency 'nokogiri', '~> 1.6.0'
24
+ spec.add_dependency 'activesupport', '~> 4.2.6'
25
25
  spec.add_dependency 'jenkins_api_client', '~> 1.0.0'
26
+ spec.add_dependency 'minitar'
26
27
  spec.add_dependency 'mixlib-shellout', '= 2.2.7' # maintaining backwards compatibility with ruby 2.1.5
28
+ spec.add_dependency 'nokogiri', '~> 1.6.0'
27
29
  spec.add_dependency 'thor', '>= 0.18.0'
28
- spec.add_dependency 'activesupport', '~> 4.2.6'
29
- spec.add_dependency 'minitar'
30
30
 
31
- spec.add_development_dependency 'rake'
32
- spec.add_development_dependency 'rspec', '~> 3.0'
33
31
  spec.add_development_dependency 'bump'
34
- spec.add_development_dependency 'json'
35
- spec.add_development_dependency 'gem-release'
36
32
  spec.add_development_dependency 'byebug'
37
- spec.add_development_dependency 'simplecov'
38
- spec.add_development_dependency 'simplecov-rcov'
39
- spec.add_development_dependency 'kwalify'
40
33
  spec.add_development_dependency 'equivalent-xml'
41
- spec.add_development_dependency 'yard-thor'
42
- spec.add_development_dependency 'yard'
34
+ spec.add_development_dependency 'gem-release'
35
+ spec.add_development_dependency 'json'
36
+ spec.add_development_dependency 'kwalify'
43
37
  spec.add_development_dependency 'pry'
38
+ spec.add_development_dependency 'rake'
39
+ spec.add_development_dependency 'rspec', '~> 3.0'
44
40
  spec.add_development_dependency 'rspec_junit_formatter'
41
+ spec.add_development_dependency 'rubocop'
42
+ spec.add_development_dependency 'simplecov'
43
+ spec.add_development_dependency 'simplecov-rcov'
45
44
  spec.add_development_dependency 'webmock', '~> 1.0'
46
- spec.add_development_dependency 'rubocop', '= 0.40.0'
45
+ spec.add_development_dependency 'yard'
46
+ spec.add_development_dependency 'yard-thor'
47
47
  end
@@ -38,7 +38,7 @@ module JenkinsPipelineBuilder
38
38
  attr_accessor :jenkins_api_creds
39
39
  end
40
40
 
41
- DEFAULT_FILE_FORMATS = %w(rb json yml yaml).freeze
41
+ DEFAULT_FILE_FORMATS = %w[rb json yml yaml].freeze
42
42
 
43
43
  # Sets up the credentials and initializes the Jenkins Pipeline Builder
44
44
  #
@@ -68,7 +68,7 @@ module JenkinsPipelineBuilder
68
68
  else
69
69
  msg = 'Credentials are not set. Please pass them as parameters or'
70
70
  msg << ' set them in the default credentials file'
71
- $stderr.puts msg
71
+ warn msg
72
72
  exit 1
73
73
  end
74
74
  end
@@ -87,12 +87,12 @@ module JenkinsPipelineBuilder
87
87
  self.jenkins_api_creds = {}.with_indifferent_access.merge options
88
88
  if jenkins_api_creds[:server] =~ Resolv::AddressRegex
89
89
  jenkins_api_creds[:server_ip] = jenkins_api_creds.delete :server
90
- elsif jenkins_api_creds[:server] =~ URI.regexp
90
+ elsif jenkins_api_creds[:server] =~ URI::DEFAULT_PARSER.make_regexp
91
91
  jenkins_api_creds[:server_url] = jenkins_api_creds.delete :server
92
92
  else
93
93
  msg = "server given (#{jenkins_api_creds[:server]}) is neither a URL nor an IP."
94
94
  msg << ' Please pass either a valid IP address or valid URI'
95
- $stderr.puts msg
95
+ warn msg
96
96
  exit 1
97
97
  end
98
98
  end
@@ -47,7 +47,7 @@ module JenkinsPipelineBuilder
47
47
  def compile_job(item, settings = {})
48
48
  new_item = compile(item, settings)
49
49
  [true, new_item]
50
- rescue => e
50
+ rescue StandardError => e
51
51
  return [false, [e.message]]
52
52
  end
53
53
 
@@ -70,9 +70,7 @@ module JenkinsPipelineBuilder
70
70
  if enable_block_present? item
71
71
  enabled_switch = resolve_value(item[:enabled], settings)
72
72
  return {} if enabled_switch == 'false'
73
- if enabled_switch != 'true'
74
- raise "Invalid value for #{item[:enabled]}: #{enabled_switch}"
75
- end
73
+ raise "Invalid value for #{item[:enabled]}: #{enabled_switch}" if enabled_switch != 'true'
76
74
  if item[:parameters].is_a? Hash
77
75
  item = item.merge item[:parameters]
78
76
  item.delete :parameters
@@ -92,7 +90,7 @@ module JenkinsPipelineBuilder
92
90
 
93
91
  def compile_string(item, settings)
94
92
  resolve_value(item, settings)
95
- rescue => e
93
+ rescue StandardError => e
96
94
  raise "Failed to resolve #{item} because: #{e.message}"
97
95
  end
98
96
 
@@ -1,12 +1,12 @@
1
1
  module JenkinsPipelineBuilder
2
2
  class ExtensionSet
3
- SET_METHODS = [
4
- :name,
5
- :plugin_id,
6
- :jenkins_name,
7
- :description,
8
- :announced,
9
- :type
3
+ SET_METHODS = %i[
4
+ name
5
+ plugin_id
6
+ jenkins_name
7
+ description
8
+ announced
9
+ type
10
10
  ].freeze
11
11
 
12
12
  SET_METHODS.each do |method_name|
@@ -113,7 +113,7 @@ module JenkinsPipelineBuilder
113
113
  yield block
114
114
  end
115
115
 
116
- [:after, :before].each do |method_name|
116
+ %i[after before].each do |method_name|
117
117
  define_method method_name do |version: '0', &block|
118
118
  if @min_version
119
119
  version = @min_version
@@ -59,10 +59,12 @@ module JenkinsPipelineBuilder
59
59
  def execute(value, n_xml)
60
60
  errors = check_parameters value
61
61
  raise ArgumentError, errors.join("\n") if errors.any?
62
- raise ArgumentError, %(Extension #{name} has no valid path
63
- Check ModuleRegistry#entries and the definition of the extension
64
- Note: job_attributes have no implicit path and must be set in the builder
65
- ).squeeze(' ') unless path
62
+ unless path
63
+ raise ArgumentError, %(Extension #{name} has no valid path
64
+ Check ModuleRegistry#entries and the definition of the extension
65
+ Note: job_attributes have no implicit path and must be set in the builder
66
+ ).squeeze(' ')
67
+ end
66
68
 
67
69
  n_builders = n_xml.xpath(path).first
68
70
  n_builders.instance_exec(value, &before) if before
@@ -54,27 +54,29 @@ build_step do
54
54
  end
55
55
  end
56
56
  else
57
- configs(class: 'empty-list') {}
57
+ configs(class: 'empty-list'){}
58
58
  end
59
59
 
60
60
  projects state[:name]
61
61
  condition 'ALWAYS'
62
62
  triggerWithNoParameters false
63
63
 
64
- block do
65
- buildStepFailureThreshold do
66
- state.generate_for_threshold(self,
67
- state.resolve_block_condition(:build_step_failure_threshold) || :failure)
68
- end
69
- unstableThreshold do
70
- state.generate_for_threshold(self,
71
- state.resolve_block_condition(:unstable_threshold) || :unstable)
72
- end
73
- failureThreshold do
74
- state.generate_for_threshold(self,
75
- state.resolve_block_condition(:failure_threshold) || :failure)
64
+ if state.block_condition?
65
+ block do
66
+ buildStepFailureThreshold do
67
+ state.generate_for_threshold(self,
68
+ state.resolve_block_condition(:build_step_failure_threshold) || :failure)
69
+ end
70
+ unstableThreshold do
71
+ state.generate_for_threshold(self,
72
+ state.resolve_block_condition(:unstable_threshold) || :unstable)
73
+ end
74
+ failureThreshold do
75
+ state.generate_for_threshold(self,
76
+ state.resolve_block_condition(:failure_threshold) || :failure)
77
+ end
76
78
  end
77
- end if state.block_condition?
79
+ end
78
80
 
79
81
  buildAllNodesWithLabel false
80
82
  end
@@ -117,11 +117,11 @@ builder do
117
117
  description 'Jenkins plugin for building Maven 2/3 jobs via a special project type.'
118
118
  jenkins_name 'Invoke Maven 3'
119
119
  announced false
120
- parameters [
121
- :mavenName,
122
- :rootPom,
123
- :goals,
124
- :options
120
+ parameters %i[
121
+ mavenName
122
+ rootPom
123
+ goals
124
+ options
125
125
  ]
126
126
 
127
127
  xml do |helper|
@@ -170,13 +170,13 @@ builder do
170
170
  description 'This plugin lets you trigger new builds when your build has completed, with various ways of specifying parameters for the new build.'
171
171
  jenkins_name 'Trigger/call builds on other projects'
172
172
  announced false
173
- parameters [
174
- :data,
175
- :project,
176
- :trigger_with_no_parameters,
177
- :fail,
178
- :mark_fail,
179
- :mark_unstable
173
+ parameters %i[
174
+ data
175
+ project
176
+ trigger_with_no_parameters
177
+ fail
178
+ mark_fail
179
+ mark_unstable
180
180
  ]
181
181
 
182
182
  xml do |helper|
@@ -359,13 +359,17 @@ builder do
359
359
  raise 'Configuration invalid. At least one of \'script\' and \'file\' keys must be specified'
360
360
  end
361
361
 
362
- scriptSource('class' => 'hudson.plugins.groovy.StringScriptSource') do
363
- command params[:script]
364
- end if params.key? :script
362
+ if params.key? :script
363
+ scriptSource('class' => 'hudson.plugins.groovy.StringScriptSource') do
364
+ command params[:script]
365
+ end
366
+ end
365
367
 
366
- scriptSource('class' => 'hudson.plugins.groovy.FileScriptSource') do
367
- scriptFile params[:file]
368
- end if params.key? :file
368
+ if params.key? :file
369
+ scriptSource('class' => 'hudson.plugins.groovy.FileScriptSource') do
370
+ scriptFile params[:file]
371
+ end
372
+ end
369
373
 
370
374
  bindings params[:bindings]
371
375
  classpath params[:classpath]
@@ -394,27 +398,27 @@ builder do
394
398
  description 'Jenkins plugin for checkmarx security audit'
395
399
  jenkins_name 'Trigger a checkmarx security audit of your build'
396
400
  announced false
397
- parameters [
398
- :serverUrl,
399
- :useOwnServerCredentials,
400
- :username,
401
- :password,
402
- :incremental,
403
- :isThisBuildIncremental,
404
- :projectName,
405
- :groupId,
406
- :skipSCMTriggers,
407
- :waitForResultsEnabled,
408
- :vulnerabilityThresholdEnabled,
409
- :highThreshold,
410
- :mediumThreshold,
411
- :lowThreshold,
412
- :preset,
413
- :presetSpecified,
414
- :generatePdfReport,
415
- :excludeFolders,
416
- :fullScansScheduled,
417
- :filterPattern
401
+ parameters %i[
402
+ serverUrl
403
+ useOwnServerCredentials
404
+ username
405
+ password
406
+ incremental
407
+ isThisBuildIncremental
408
+ projectName
409
+ groupId
410
+ skipSCMTriggers
411
+ waitForResultsEnabled
412
+ vulnerabilityThresholdEnabled
413
+ highThreshold
414
+ mediumThreshold
415
+ lowThreshold
416
+ preset
417
+ presetSpecified
418
+ generatePdfReport
419
+ excludeFolders
420
+ fullScansScheduled
421
+ filterPattern
418
422
  ]
419
423
 
420
424
  xml do |params|
@@ -450,13 +454,13 @@ builder do
450
454
  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.'
451
455
  jenkins_name 'SonarQube Plugin'
452
456
  announced false
453
- parameters [
454
- :sonarInstallation,
455
- :taskToRun,
456
- :jdk,
457
- :pathToProjectProperties,
458
- :projectProperties,
459
- :jvmOptions
457
+ parameters %i[
458
+ sonarInstallation
459
+ taskToRun
460
+ jdk
461
+ pathToProjectProperties
462
+ projectProperties
463
+ jvmOptions
460
464
  ]
461
465
 
462
466
  xml do |params|
@@ -130,17 +130,17 @@ job_attribute do
130
130
  announced false
131
131
 
132
132
  version '0' do
133
- parameters [
134
- :remote_name,
135
- :refspec,
136
- :local_branch,
137
- :recursive_update,
138
- :wipe_workspace,
139
- :excluded_users,
140
- :skip_tag,
141
- :remote_url,
142
- :excluded_regions,
143
- :included_regions
133
+ parameters %i[
134
+ remote_name
135
+ refspec
136
+ local_branch
137
+ recursive_update
138
+ wipe_workspace
139
+ excluded_users
140
+ skip_tag
141
+ remote_url
142
+ excluded_regions
143
+ included_regions
144
144
  ]
145
145
 
146
146
  # XML preprocessing
@@ -183,19 +183,19 @@ job_attribute do
183
183
  end
184
184
 
185
185
  version '2.0' do
186
- parameters [
187
- :changelog_to_branch,
188
- :credentials_id,
189
- :excluded_regions,
190
- :excluded_users,
191
- :included_regions,
192
- :local_branch,
193
- :recursive_update,
194
- :refspec,
195
- :remote_name,
196
- :remote_url,
197
- :skip_tag,
198
- :wipe_workspace
186
+ parameters %i[
187
+ changelog_to_branch
188
+ credentials_id
189
+ excluded_regions
190
+ excluded_users
191
+ included_regions
192
+ local_branch
193
+ recursive_update
194
+ refspec
195
+ remote_name
196
+ remote_url
197
+ skip_tag
198
+ wipe_workspace
199
199
  ]
200
200
 
201
201
  before do |params|
@@ -408,7 +408,7 @@ job_attribute do
408
408
  announced false
409
409
 
410
410
  xml path: '//concurrentBuild' do |params|
411
- (params == true) ? 'true' : 'false'
411
+ params == true ? 'true' : 'false'
412
412
  end
413
413
  end
414
414
 
@@ -30,10 +30,10 @@ end
30
30
  promotion_condition do
31
31
  name :parameterized_self_promotion
32
32
  plugin_id 'promoted-builds'
33
- parameters [
34
- :parameter_name,
35
- :parameter_value,
36
- :even_if_unstable
33
+ parameters %i[
34
+ parameter_name
35
+ parameter_value
36
+ even_if_unstable
37
37
  ]
38
38
 
39
39
  xml do |params|
@@ -50,9 +50,9 @@ end
50
50
  promotion_condition do
51
51
  name :downstream_pass
52
52
  plugin_id 'promoted-builds'
53
- parameters [
54
- :jobs,
55
- :even_if_unstable
53
+ parameters %i[
54
+ jobs
55
+ even_if_unstable
56
56
  ]
57
57
 
58
58
  xml do |params|
@@ -294,11 +294,9 @@ publisher do
294
294
  groovyScript params[:groovy_script]
295
295
  behavior params[:behavior] || '0'
296
296
  runFormMatrixParent 'false'
297
- if params[:additional_classpaths]
298
- params[:additional_classpaths].each do |path|
299
- send('org.jvnet.hudson.plugins.groovypostbuild.GroovyScriptPath') do
300
- path path[:path] || '/'
301
- end
297
+ params[:additional_classpaths] && params[:additional_classpaths].each do |path|
298
+ send('org.jvnet.hudson.plugins.groovypostbuild.GroovyScriptPath') do
299
+ path path[:path] || '/'
302
300
  end
303
301
  end
304
302
  end
@@ -543,16 +541,14 @@ publisher do
543
541
  xml do |params|
544
542
  send('htmlpublisher.HtmlPublisher', 'plugin' => 'htmlpublisher') do
545
543
  send('reportTargets') do
546
- unless params[:report_targets].nil?
547
- params[:report_targets].each do |target|
548
- send('htmlpublisher.HtmlPublisherTarget') do
549
- reportName target[:report_title] || 'HTML Report'
550
- reportDir target[:report_dir] || ''
551
- reportFiles target[:index_pages] || 'index.html'
552
- keepAll target[:keep_past] || false
553
- allowMissing target[:allow_missing] || false
554
- wrapperName 'htmlpublisher-wrapper.html'
555
- end
544
+ params[:report_targets] && params[:report_targets].each do |target|
545
+ send('htmlpublisher.HtmlPublisherTarget') do
546
+ reportName target[:report_title] || 'HTML Report'
547
+ reportDir target[:report_dir] || ''
548
+ reportFiles target[:index_pages] || 'index.html'
549
+ keepAll target[:keep_past] || false
550
+ allowMissing target[:allow_missing] || false
551
+ wrapperName 'htmlpublisher-wrapper.html'
556
552
  end
557
553
  end
558
554
  end
@@ -592,15 +588,13 @@ publisher do
592
588
  xml do |params|
593
589
  send('xunit', 'plugin' => 'xunit') do
594
590
  send('types') do
595
- unless params[:types].nil?
596
- params[:types].each do |type|
597
- send(type[:type]) do
598
- pattern type[:pattern]
599
- skipNoTestFiles type[:skip_no_test_files] || false
600
- failIfNotNew type[:fail_if_not_new] || true
601
- deleteOutputFiles type[:delete_output_files] || true
602
- stopProcessingIfError type[:stop_processing_error] || true
603
- end
591
+ params[:types] && params[:types].each do |type|
592
+ send(type[:type]) do
593
+ pattern type[:pattern]
594
+ skipNoTestFiles type[:skip_no_test_files] || false
595
+ failIfNotNew type[:fail_if_not_new] || true
596
+ deleteOutputFiles type[:delete_output_files] || true
597
+ stopProcessingIfError type[:stop_processing_error] || true
604
598
  end
605
599
  end
606
600
  end
@@ -682,3 +676,21 @@ publisher do
682
676
  end
683
677
  end
684
678
  end
679
+
680
+ publisher do
681
+ name :github_pr_coverage_status_reporter
682
+ plugin_id 'github-pr-coverage-status'
683
+ description 'Code coverage icon for GitHub pull requests'
684
+ jenkins_name 'GitHub Pull Request Coverage Status'
685
+ announced false
686
+
687
+ xml do |action|
688
+ if action == 'compare'
689
+ send('com.github.terma.jenkins.githubprcoveragestatus.CompareCoverageAction')
690
+ elsif action == 'master'
691
+ send('com.github.terma.jenkins.githubprcoveragestatus.MasterCoverageAction')
692
+ else
693
+ raise 'Invalid plugin configuration. github_pr_coverage_status_reporter value must be "compare" or "master"'
694
+ end
695
+ end
696
+ end
@@ -26,7 +26,7 @@ wrapper do
26
26
  announced false
27
27
  jenkins_name 'Color ANSI Console Output'
28
28
  description 'This plugin adds support for ANSI escape sequences, including color, to Console Output.'
29
- parameters false
29
+
30
30
  xml do |_|
31
31
  send('hudson.plugins.ansicolor.AnsiColorBuildWrapper') do
32
32
  colorMapName 'xterm'
@@ -131,7 +131,7 @@ module JenkinsPipelineBuilder
131
131
  errors = {}
132
132
  project_body = project[:value]
133
133
 
134
- %i(jobs views promotions).each do |key|
134
+ %i[jobs views promotions].each do |key|
135
135
  next unless project_body[key]
136
136
 
137
137
  Utils.symbolize_with_empty_hash!(project_body[key])
@@ -193,9 +193,7 @@ module JenkinsPipelineBuilder
193
193
 
194
194
  errors = publish_jobs(compiled_project[:value][:jobs])
195
195
 
196
- if compiled_project[:value][:views]
197
- publish_views(compiled_project[:value][:views])
198
- end
196
+ publish_views(compiled_project[:value][:views]) if compiled_project[:value][:views]
199
197
 
200
198
  if compiled_project[:value][:promotions]
201
199
  publish_promotions(compiled_project[:value][:promotions], compiled_project[:value][:jobs])
@@ -212,9 +210,10 @@ module JenkinsPipelineBuilder
212
210
  # Converts a list of jobs that might have a list of promoted_builds to
213
211
  # A hash of promoted_builds names => associated job names
214
212
  promotion_job_pairs = jobs.each_with_object({}) do |j, acc|
213
+ next unless j[:result][:promoted_builds]
215
214
  j[:result][:promoted_builds].each do |promotion_name|
216
215
  acc[promotion_name] = j[:result][:name]
217
- end if j[:result][:promoted_builds]
216
+ end
218
217
  end
219
218
 
220
219
  promotions.each do |promotion|
@@ -39,7 +39,7 @@ module JenkinsPipelineBuilder
39
39
 
40
40
  private
41
41
 
42
- [:free_style, :pull_request_generator].each do |method_name|
42
+ %i[free_style pull_request_generator].each do |method_name|
43
43
  define_method "update_#{method_name}" do
44
44
  @xml
45
45
  end
@@ -50,7 +50,7 @@ module JenkinsPipelineBuilder
50
50
  end
51
51
 
52
52
  def job_methods
53
- %w(job_dsl multi_project build_flow free_style pull_request_generator)
53
+ %w[job_dsl multi_project build_flow free_style pull_request_generator]
54
54
  end
55
55
 
56
56
  def local_output(xml)
@@ -89,10 +89,12 @@ module JenkinsPipelineBuilder
89
89
  return
90
90
  end
91
91
 
92
- raise TypeError, %(Expected Hash received #{value.class}.
93
- Verify that the pipeline section is made up of a single {key: Hash/Object} pair
94
- See the definition for:
95
- \t#{section}).squeeze(' ') unless value.is_a? Hash
92
+ unless value.is_a? Hash
93
+ raise TypeError, %(Expected Hash received #{value.class}.
94
+ Verify that the pipeline section is made up of a single {key: Hash/Object} pair
95
+ See the definition for:
96
+ \t#{section}).squeeze(' ')
97
+ end
96
98
 
97
99
  name = value[:name]
98
100
  process_collection! name, key, value, remote
@@ -52,8 +52,10 @@ module JenkinsPipelineBuilder
52
52
  job[:scm_params] ||= {}
53
53
  job[:scm_params][:refspec] = "refs/pull/#{pr}/head:refs/remotes/origin/pr/#{pr}/head"
54
54
  job[:scm_params][:changelog_to_branch] ||= {}
55
- job[:scm_params][:changelog_to_branch]
56
- .merge!(remote: 'origin', branch: "pr/#{pr}/head") if Gem::Version.new(2.0) < git_version
55
+ if Gem::Version.new(2.0) < git_version
56
+ job[:scm_params][:changelog_to_branch]
57
+ .merge!(remote: 'origin', branch: "pr/#{pr}/head")
58
+ end
57
59
  end
58
60
 
59
61
  def active_prs(git_url, git_org, git_repo)
@@ -77,9 +77,7 @@ module JenkinsPipelineBuilder
77
77
  else
78
78
  path = File.join(path, template[:name]) unless template[:name] == 'default'
79
79
  # If we are looking for the newest version or no version was set
80
- if use_newest_version? template, path
81
- template[:version] = highest_template_version path
82
- end
80
+ template[:version] = highest_template_version path if use_newest_version? template, path
83
81
  path = File.join(path, template[:version]) unless template[:version].nil?
84
82
  path = File.join(path, 'pipeline')
85
83
  end
@@ -21,5 +21,5 @@
21
21
  #
22
22
 
23
23
  module JenkinsPipelineBuilder
24
- VERSION = '1.5.2'.freeze
24
+ VERSION = '1.6.0'.freeze
25
25
  end
@@ -43,7 +43,7 @@ describe JenkinsPipelineBuilder::CLI::Helper do
43
43
 
44
44
  it 'should puts an error to stdout and exit if server is invalid' do
45
45
  options[:server] = 'not_valid_at_all'
46
- expect($stderr).to receive(:puts).with(/server given \(not_valid_at_all\)/)
46
+ expect(described_class).to receive(:warn).with(/server given \(not_valid_at_all\)/)
47
47
  expect { described_class.setup(options) }.to raise_error(SystemExit, 'exit')
48
48
  end
49
49
  end
@@ -99,7 +99,7 @@ describe JenkinsPipelineBuilder::CLI::Helper do
99
99
 
100
100
  it 'should puts and error to stdout and exit if no credentials are passed' do
101
101
  allow(File).to receive(:exist?).and_return(false)
102
- expect($stderr).to receive(:puts).with(/Credentials are not set/)
102
+ expect(described_class).to receive(:warn).with(/Credentials are not set/)
103
103
  expect { described_class.setup({}) }.to raise_error(SystemExit, 'exit')
104
104
  end
105
105
  end
@@ -123,10 +123,10 @@ describe JenkinsPipelineBuilder::CLI::Helper do
123
123
  it "loads a default file ending in .#{suffix}" do
124
124
  file_suffixes.each do |ending|
125
125
  expect(File).to receive(:exist?).with("#{default_creds_base}.#{ending}")
126
- .and_return ending == suffix
126
+ .and_return ending == suffix
127
127
  end
128
128
  expect(File).to receive(:expand_path).with("#{default_creds_base}.#{suffix}")
129
- .and_return "#{creds_file_base}.#{suffix}"
129
+ .and_return "#{creds_file_base}.#{suffix}"
130
130
 
131
131
  described_class.setup({})
132
132
  end
@@ -140,7 +140,7 @@ describe JenkinsPipelineBuilder::CLI::Helper do
140
140
  # Stub the existence of the used and extraneous 'found' files
141
141
  file_suffixes.each do |suffix|
142
142
  expect(File).to receive(:exist?).with("#{default_creds_base}.#{suffix}")
143
- .and_return suffix == used_suffix || suffix == found_suffix
143
+ .and_return suffix == used_suffix || suffix == found_suffix
144
144
  end
145
145
  expect(JenkinsPipelineBuilder.logger).to receive(:warn)
146
146
  .with(/'#{default_creds_base}\.#{used_suffix}' but '#{default_creds_base}\.#{found_suffix}' found\./)
@@ -1,7 +1,7 @@
1
1
  require File.expand_path('../spec_helper', __FILE__)
2
2
 
3
3
  describe JenkinsPipelineBuilder::ExtensionSet do
4
- subject(:set) { JenkinsPipelineBuilder::ExtensionSet.new('foo') {} }
4
+ subject(:set) { JenkinsPipelineBuilder::ExtensionSet.new('foo'){} }
5
5
 
6
6
  before :each do
7
7
  set.name 'example'
@@ -87,7 +87,7 @@ describe 'job_attributes' do
87
87
 
88
88
  context 'choice parameter' do
89
89
  let(:params) do
90
- { parameters: [{ type: 'choice', values: [:foo, :bar], name: :foo, description: :desc, default: :default }] }
90
+ { parameters: [{ type: 'choice', values: %i[foo bar], name: :foo, description: :desc, default: :default }] }
91
91
  end
92
92
 
93
93
  it 'generates correct config' do
@@ -25,6 +25,7 @@ PUBLISHERS = {
25
25
  email_ext: ['0'],
26
26
  email_notifications: ['0'],
27
27
  git: ['0'],
28
+ github_pr_coverage_status_reporter: ['0'],
28
29
  groovy_postbuild: ['0'],
29
30
  hipchat: ['0', '0.1.9', '2.0.0'],
30
31
  html_publisher: ['0'],
@@ -39,6 +39,10 @@ describe 'wrappers' do
39
39
  end
40
40
 
41
41
  it 'fails parameters are passed' do
42
+ # This test is pending because the ansicolor wrapper has a property `parameters false` which is intended to
43
+ # indicate that the plugin does not take any parameters. This does not work as expected, however, after
44
+ # updating code to meet updated Rubocop standards
45
+ pending
42
46
  params = { wrappers: { ansicolor: { config: false } } }
43
47
  expect do
44
48
  JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
@@ -252,7 +252,7 @@ describe JenkinsPipelineBuilder::Generator do
252
252
  describe '#projects' do
253
253
  it 'returns a list of projects' do
254
254
  path = File.expand_path('../fixtures/generator_tests/multi_project', __FILE__)
255
- expect(@generator.projects(path)).to eq %w(SamplePipeline1 SamplePipeline2 SamplePipeline3)
255
+ expect(@generator.projects(path)).to eq %w[SamplePipeline1 SamplePipeline2 SamplePipeline3]
256
256
  end
257
257
  end
258
258
 
@@ -97,7 +97,7 @@ describe JenkinsPipelineBuilder::ModuleRegistry do
97
97
  end
98
98
 
99
99
  it 'calls the xml block when executing the item' do
100
- @ext.xml -> (_) { raise XmlException, 'foo' }
100
+ @ext.xml ->(_) { raise XmlException, 'foo' }
101
101
 
102
102
  expect do
103
103
  JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
@@ -105,7 +105,7 @@ describe JenkinsPipelineBuilder::ModuleRegistry do
105
105
  end
106
106
 
107
107
  it 'calls the before block' do
108
- @ext.before -> (_) { raise BeforeException, 'foo' }
108
+ @ext.before ->(_) { raise BeforeException, 'foo' }
109
109
 
110
110
  expect do
111
111
  JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
@@ -113,7 +113,7 @@ describe JenkinsPipelineBuilder::ModuleRegistry do
113
113
  end
114
114
 
115
115
  it 'calls the after block' do
116
- @ext.after -> (_) { raise AfterException, 'foo' }
116
+ @ext.after ->(_) { raise AfterException, 'foo' }
117
117
 
118
118
  expect do
119
119
  JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
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: 1.5.2
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Moochnick
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-12-08 00:00:00.000000000 Z
12
+ date: 2017-12-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: nokogiri
15
+ name: activesupport
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 1.6.0
20
+ version: 4.2.6
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 1.6.0
27
+ version: 4.2.6
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: jenkins_api_client
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -40,63 +40,63 @@ dependencies:
40
40
  - !ruby/object:Gem::Version
41
41
  version: 1.0.0
42
42
  - !ruby/object:Gem::Dependency
43
- name: mixlib-shellout
43
+ name: minitar
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '='
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: 2.2.7
48
+ version: '0'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - '='
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: 2.2.7
55
+ version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
- name: thor
57
+ name: mixlib-shellout
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ">="
60
+ - - '='
61
61
  - !ruby/object:Gem::Version
62
- version: 0.18.0
62
+ version: 2.2.7
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ">="
67
+ - - '='
68
68
  - !ruby/object:Gem::Version
69
- version: 0.18.0
69
+ version: 2.2.7
70
70
  - !ruby/object:Gem::Dependency
71
- name: activesupport
71
+ name: nokogiri
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: 4.2.6
76
+ version: 1.6.0
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: 4.2.6
83
+ version: 1.6.0
84
84
  - !ruby/object:Gem::Dependency
85
- name: minitar
85
+ name: thor
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ">="
89
89
  - !ruby/object:Gem::Version
90
- version: '0'
90
+ version: 0.18.0
91
91
  type: :runtime
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - ">="
96
96
  - !ruby/object:Gem::Version
97
- version: '0'
97
+ version: 0.18.0
98
98
  - !ruby/object:Gem::Dependency
99
- name: rake
99
+ name: bump
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - ">="
@@ -110,21 +110,7 @@ dependencies:
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  - !ruby/object:Gem::Dependency
113
- name: rspec
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - "~>"
117
- - !ruby/object:Gem::Version
118
- version: '3.0'
119
- type: :development
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - "~>"
124
- - !ruby/object:Gem::Version
125
- version: '3.0'
126
- - !ruby/object:Gem::Dependency
127
- name: bump
113
+ name: byebug
128
114
  requirement: !ruby/object:Gem::Requirement
129
115
  requirements:
130
116
  - - ">="
@@ -138,7 +124,7 @@ dependencies:
138
124
  - !ruby/object:Gem::Version
139
125
  version: '0'
140
126
  - !ruby/object:Gem::Dependency
141
- name: json
127
+ name: equivalent-xml
142
128
  requirement: !ruby/object:Gem::Requirement
143
129
  requirements:
144
130
  - - ">="
@@ -166,7 +152,7 @@ dependencies:
166
152
  - !ruby/object:Gem::Version
167
153
  version: '0'
168
154
  - !ruby/object:Gem::Dependency
169
- name: byebug
155
+ name: json
170
156
  requirement: !ruby/object:Gem::Requirement
171
157
  requirements:
172
158
  - - ">="
@@ -180,7 +166,7 @@ dependencies:
180
166
  - !ruby/object:Gem::Version
181
167
  version: '0'
182
168
  - !ruby/object:Gem::Dependency
183
- name: simplecov
169
+ name: kwalify
184
170
  requirement: !ruby/object:Gem::Requirement
185
171
  requirements:
186
172
  - - ">="
@@ -194,7 +180,7 @@ dependencies:
194
180
  - !ruby/object:Gem::Version
195
181
  version: '0'
196
182
  - !ruby/object:Gem::Dependency
197
- name: simplecov-rcov
183
+ name: pry
198
184
  requirement: !ruby/object:Gem::Requirement
199
185
  requirements:
200
186
  - - ">="
@@ -208,7 +194,7 @@ dependencies:
208
194
  - !ruby/object:Gem::Version
209
195
  version: '0'
210
196
  - !ruby/object:Gem::Dependency
211
- name: kwalify
197
+ name: rake
212
198
  requirement: !ruby/object:Gem::Requirement
213
199
  requirements:
214
200
  - - ">="
@@ -222,21 +208,21 @@ dependencies:
222
208
  - !ruby/object:Gem::Version
223
209
  version: '0'
224
210
  - !ruby/object:Gem::Dependency
225
- name: equivalent-xml
211
+ name: rspec
226
212
  requirement: !ruby/object:Gem::Requirement
227
213
  requirements:
228
- - - ">="
214
+ - - "~>"
229
215
  - !ruby/object:Gem::Version
230
- version: '0'
216
+ version: '3.0'
231
217
  type: :development
232
218
  prerelease: false
233
219
  version_requirements: !ruby/object:Gem::Requirement
234
220
  requirements:
235
- - - ">="
221
+ - - "~>"
236
222
  - !ruby/object:Gem::Version
237
- version: '0'
223
+ version: '3.0'
238
224
  - !ruby/object:Gem::Dependency
239
- name: yard-thor
225
+ name: rspec_junit_formatter
240
226
  requirement: !ruby/object:Gem::Requirement
241
227
  requirements:
242
228
  - - ">="
@@ -250,7 +236,7 @@ dependencies:
250
236
  - !ruby/object:Gem::Version
251
237
  version: '0'
252
238
  - !ruby/object:Gem::Dependency
253
- name: yard
239
+ name: rubocop
254
240
  requirement: !ruby/object:Gem::Requirement
255
241
  requirements:
256
242
  - - ">="
@@ -264,7 +250,7 @@ dependencies:
264
250
  - !ruby/object:Gem::Version
265
251
  version: '0'
266
252
  - !ruby/object:Gem::Dependency
267
- name: pry
253
+ name: simplecov
268
254
  requirement: !ruby/object:Gem::Requirement
269
255
  requirements:
270
256
  - - ">="
@@ -278,7 +264,7 @@ dependencies:
278
264
  - !ruby/object:Gem::Version
279
265
  version: '0'
280
266
  - !ruby/object:Gem::Dependency
281
- name: rspec_junit_formatter
267
+ name: simplecov-rcov
282
268
  requirement: !ruby/object:Gem::Requirement
283
269
  requirements:
284
270
  - - ">="
@@ -306,19 +292,33 @@ dependencies:
306
292
  - !ruby/object:Gem::Version
307
293
  version: '1.0'
308
294
  - !ruby/object:Gem::Dependency
309
- name: rubocop
295
+ name: yard
310
296
  requirement: !ruby/object:Gem::Requirement
311
297
  requirements:
312
- - - '='
298
+ - - ">="
313
299
  - !ruby/object:Gem::Version
314
- version: 0.40.0
300
+ version: '0'
315
301
  type: :development
316
302
  prerelease: false
317
303
  version_requirements: !ruby/object:Gem::Requirement
318
304
  requirements:
319
- - - '='
305
+ - - ">="
306
+ - !ruby/object:Gem::Version
307
+ version: '0'
308
+ - !ruby/object:Gem::Dependency
309
+ name: yard-thor
310
+ requirement: !ruby/object:Gem::Requirement
311
+ requirements:
312
+ - - ">="
320
313
  - !ruby/object:Gem::Version
321
- version: 0.40.0
314
+ version: '0'
315
+ type: :development
316
+ prerelease: false
317
+ version_requirements: !ruby/object:Gem::Requirement
318
+ requirements:
319
+ - - ">="
320
+ - !ruby/object:Gem::Version
321
+ version: '0'
322
322
  description: |-
323
323
  This is a simple and easy-to-use Jenkins Pipeline generator with features focused on
324
324
  automating Job & Pipeline creation from the YAML files checked-in with your application source code
@@ -334,6 +334,7 @@ files:
334
334
  - ".gitignore"
335
335
  - ".rspec"
336
336
  - ".rubocop.yml"
337
+ - ".rubocop_todo.yml"
337
338
  - ".ruby-gemset"
338
339
  - ".ruby-version"
339
340
  - ".simplecov"