jenkins_pipeline_builder 0.10.16 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +8 -8
  2. data/.rubocop.yml +4 -4
  3. data/lib/jenkins_pipeline_builder.rb +5 -0
  4. data/lib/jenkins_pipeline_builder/compiler.rb +27 -24
  5. data/lib/jenkins_pipeline_builder/extension_dsl.rb +1 -0
  6. data/lib/jenkins_pipeline_builder/extension_set.rb +8 -8
  7. data/lib/jenkins_pipeline_builder/extensions.rb +12 -24
  8. data/lib/jenkins_pipeline_builder/extensions/builders.rb +36 -27
  9. data/lib/jenkins_pipeline_builder/extensions/helpers/builders/blocking_downstream_helper.rb +18 -0
  10. data/lib/jenkins_pipeline_builder/extensions/helpers/builders/maven3_helper.rb +11 -0
  11. data/lib/jenkins_pipeline_builder/extensions/helpers/extension_helper.rb +26 -0
  12. data/lib/jenkins_pipeline_builder/extensions/helpers/job_attributes/parameters_helper.rb +18 -0
  13. data/lib/jenkins_pipeline_builder/extensions/helpers/publishers/cobertura_report_helper.rb +40 -0
  14. data/lib/jenkins_pipeline_builder/extensions/helpers/publishers/email_ext_helper.rb +148 -0
  15. data/lib/jenkins_pipeline_builder/extensions/helpers/triggers/upstream_helper.rb +21 -0
  16. data/lib/jenkins_pipeline_builder/extensions/job_attributes.rb +1 -15
  17. data/lib/jenkins_pipeline_builder/extensions/publishers.rb +263 -6
  18. data/lib/jenkins_pipeline_builder/extensions/triggers.rb +3 -17
  19. data/lib/jenkins_pipeline_builder/extensions/wrappers.rb +3 -3
  20. data/lib/jenkins_pipeline_builder/generator.rb +10 -11
  21. data/lib/jenkins_pipeline_builder/job.rb +29 -25
  22. data/lib/jenkins_pipeline_builder/job_collection.rb +31 -21
  23. data/lib/jenkins_pipeline_builder/module_registry.rb +5 -1
  24. data/lib/jenkins_pipeline_builder/project.rb +28 -0
  25. data/lib/jenkins_pipeline_builder/pull_request_generator.rb +8 -8
  26. data/lib/jenkins_pipeline_builder/version.rb +1 -1
  27. data/spec/lib/jenkins_pipeline_builder/extension_dsl_spec.rb +43 -0
  28. data/spec/lib/jenkins_pipeline_builder/extension_set_spec.rb +110 -0
  29. data/spec/lib/jenkins_pipeline_builder/extensions/builders_spec.rb +56 -0
  30. data/spec/lib/jenkins_pipeline_builder/extensions/job_attributes_spec.rb +85 -0
  31. data/spec/lib/jenkins_pipeline_builder/extensions/publishers_spec.rb +81 -9
  32. data/spec/lib/jenkins_pipeline_builder/extensions/registered_spec.rb +134 -0
  33. data/spec/lib/jenkins_pipeline_builder/extensions/triggers_spec.rb +88 -0
  34. data/spec/lib/jenkins_pipeline_builder/extensions_spec.rb +0 -97
  35. data/spec/lib/jenkins_pipeline_builder/fixtures/job_collection/extensions/extension.rb +11 -0
  36. data/spec/lib/jenkins_pipeline_builder/fixtures/job_collection/extensions/helpers/my_test_thing_helper.rb +5 -0
  37. data/spec/lib/jenkins_pipeline_builder/job_collection_spec.rb +46 -0
  38. data/spec/lib/jenkins_pipeline_builder/module_registry_spec.rb +1 -110
  39. data/spec/lib/jenkins_pipeline_builder/spec_helper.rb +12 -0
  40. metadata +24 -2
@@ -127,100 +127,3 @@ describe JenkinsPipelineBuilder::Extension do
127
127
  end
128
128
  end
129
129
  end
130
-
131
- describe JenkinsPipelineBuilder::ExtensionSet do
132
- subject(:set) { JenkinsPipelineBuilder::ExtensionSet.new('foo') {} }
133
-
134
- before :each do
135
- set.name 'example'
136
- end
137
-
138
- context 'xml' do
139
- it 'returns the block for the correct version'
140
- it 'sets the min_version if a parameter is provided' do
141
- set.xml version: '0.2' do
142
- true
143
- end
144
- expect(set.blocks).to have_key '0.2'
145
- end
146
- it 'uses the path if provided' do
147
- set.xml path: 'foo' do
148
- true
149
- end
150
- expect(set.blocks['0'][:path]).to eq 'foo'
151
- end
152
- end
153
-
154
- context '#extension' do
155
- def new_ext(version = '0.0')
156
- ext = JenkinsPipelineBuilder::Extension.new
157
- ext.name 'foo'
158
- ext.plugin_id 'foo'
159
- ext.min_version version
160
- ext.xml -> { true }
161
- ext.type 'foo'
162
- ext.path 'foo'
163
- ext
164
- end
165
-
166
- def ext_versions(versions)
167
- versions.each do |v|
168
- ext = new_ext(v)
169
- expect(ext).to be_valid
170
- set.extensions << ext
171
- end
172
-
173
- expect(set).to be_valid
174
- expect(set.extensions.size).to eq versions.size
175
- end
176
-
177
- it 'returns an extension' do
178
- ext_versions ['0.0']
179
- set.installed_version = '0.1'
180
- expect(set.extension).to be_kind_of JenkinsPipelineBuilder::Extension
181
- end
182
-
183
- it 'returns the highest that is lower than the installed version' do
184
- ext_versions ['0.0', '0.2']
185
-
186
- set.installed_version = '0.1'
187
-
188
- expect(set.extension.min_version).to eq '0.0'
189
- end
190
-
191
- it 'returns highest available if the installed version is higher' do
192
- ext_versions ['0.0', '0.2']
193
-
194
- set.installed_version = '0.3'
195
-
196
- expect(set.extension.min_version).to eq '0.2'
197
- end
198
-
199
- it 'works for complicated version comparions' do
200
- ext_versions ['10.5', '9.2', '100.4']
201
-
202
- set.installed_version = '11.3'
203
-
204
- expect(set.extension.min_version).to eq '10.5'
205
- end
206
-
207
- it 'raises an error if the registered versions are too high' do
208
- ext_versions ['10.5', '9.2']
209
-
210
- set.installed_version = '1.3'
211
-
212
- expect { set.extension.min_version }.to raise_error
213
- end
214
-
215
- it 'works for snapshot/beta stuff' do
216
- ext_versions ['1.9', '2.3']
217
-
218
- set.installed_version = '2.0-SNAPSHOT (private-06/06/2014 09:51-bgaulin)'
219
- # Other examples
220
- # set.installed_version = '2.0-beta-1'
221
- # set.installed_version = '2.0+build.93'
222
- # set.installed_version = '2.0.8'
223
- expect(set.extension.min_version).to eq '1.9'
224
- end
225
- end
226
- end
@@ -0,0 +1,11 @@
1
+ publisher do
2
+ name :my_test_thing
3
+ plugin_id 'test-thing'
4
+ description 'test plugin'
5
+ jenkins_name 'test plugin'
6
+
7
+ xml do |helper|
8
+ stuff 'asdf'
9
+ thing(helper.cool_method)
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ class MyTestThingHelper < ExtensionHelper
2
+ def cool_method
3
+ 'cool_stuff_method'
4
+ end
5
+ end
@@ -0,0 +1,46 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ describe JenkinsPipelineBuilder::JobCollection do
4
+ before :all do
5
+ JenkinsPipelineBuilder.credentials = {
6
+ server_ip: '127.0.0.1',
7
+ server_port: 8080,
8
+ username: 'username',
9
+ password: 'password',
10
+ log_location: '/dev/null'
11
+ }
12
+ end
13
+
14
+ after :each do
15
+ JenkinsPipelineBuilder.registry.clear_versions
16
+ end
17
+
18
+ before :each do
19
+ JenkinsPipelineBuilder.debug!
20
+ end
21
+
22
+ context '#load_from_path' do
23
+ before :all do
24
+ path = File.expand_path('../fixtures/job_collection/', __FILE__)
25
+ described_class.new.load_from_path path
26
+ end
27
+
28
+ after :all do
29
+ JenkinsPipelineBuilder.registry.registry[:job][:publishers].delete(:my_test_thing)
30
+ end
31
+
32
+ it 'loads extensions' do
33
+ expect(JenkinsPipelineBuilder.registry.registry[:job][:publishers]).to have_key :my_test_thing
34
+ end
35
+
36
+ it 'loads extension helpers' do
37
+ extension = JenkinsPipelineBuilder.registry.registry[:job][:publishers][:my_test_thing].extension
38
+ builder = Nokogiri::XML::Builder.new { |xml| xml.publishers }
39
+ xml = builder.doc
40
+ expect(extension.execute({}, xml)).to be true
41
+ node = xml.css('thing').first
42
+ expect(node.name).to eq 'thing'
43
+ expect(node.content).to eq 'cool_stuff_method'
44
+ end
45
+ end
46
+ end
@@ -13,117 +13,8 @@ describe JenkinsPipelineBuilder::ModuleRegistry do
13
13
 
14
14
  expect(registry.get('job/foo').name).to eq :foo
15
15
  end
16
-
17
- it 'registered the builders correctly' do
18
- builders = {
19
- multi_job: ['0'],
20
- maven3: ['0'],
21
- shell_command: ['0'],
22
- inject_vars_file: ['0'],
23
- blocking_downstream: ['0'],
24
- remote_job: ['0'],
25
- copy_artifact: ['0']
26
- }
27
- registry = JenkinsPipelineBuilder.registry.registry
28
- expect(registry[:job][:builders].size).to eq builders.size
29
- builders.each do |builder, versions|
30
- expect(registry[:job][:builders]).to have_key builder
31
-
32
- versions.each do |version|
33
- expect(registry[:job][:builders][builder]).to have_min_version version
34
- end
35
- end
36
- end
37
-
38
- it 'registered the triggers correctly' do
39
- triggers = {
40
- git_push: ['0'],
41
- scm_polling: ['0'],
42
- periodic_build: ['0'],
43
- upstream: ['0']
44
- }
45
- registry = JenkinsPipelineBuilder.registry.registry
46
- expect(registry[:job][:triggers].size).to eq triggers.size
47
- triggers.each do |trigger, versions|
48
- expect(registry[:job][:triggers]).to have_key trigger
49
-
50
- versions.each do |version|
51
- expect(registry[:job][:triggers][trigger]).to have_min_version version
52
- end
53
- end
54
- end
55
- it 'registered the job_attributes correctly' do
56
- job_attributes = {
57
- description: ['0'],
58
- disabled: ['0'],
59
- scm_params: ['0'],
60
- hipchat: ['0'],
61
- priority: ['0'],
62
- parameters: ['0'],
63
- discard_old: ['0'],
64
- throttle: ['0'],
65
- prepare_environment: ['0'],
66
- concurrent_build: ['0'],
67
- inject_env_vars_pre_scm: ['0'],
68
- promoted_builds: ['0']
69
- }
70
- registry = JenkinsPipelineBuilder.registry.registry
71
- # There are 4 sub types so, we don't count those
72
- expect(registry[:job].size - 4).to eq job_attributes.size
73
- job_attributes.each do |job_attribute, versions|
74
- expect(registry[:job]).to have_key job_attribute
75
-
76
- versions.each do |version|
77
- expect(registry[:job][job_attribute]).to have_min_version version
78
- end
79
- end
80
- end
81
- it 'registered the publishers correctly' do
82
- publishers = {
83
- description_setter: ['0'],
84
- downstream: ['0'],
85
- hipchat: ['0'],
86
- git: ['0'],
87
- junit_result: ['0'],
88
- coverage_result: ['0'],
89
- performance_plugin: ['0'],
90
- post_build_script: ['0'],
91
- groovy_postbuild: ['0'],
92
- archive_artifact: ['0'],
93
- email_notifications: ['0'],
94
- sonar_result: ['0']
95
- }
96
- registry = JenkinsPipelineBuilder.registry.registry
97
- expect(registry[:job][:publishers].keys).to match_array publishers.keys
98
- publishers.each do |publisher, versions|
99
- versions.each do |version|
100
- expect(registry[:job][:publishers][publisher]).to have_min_version version
101
- end
102
- end
103
- end
104
- it 'registered the wrappers correctly' do
105
- wrappers = {
106
- ansicolor: ['0'],
107
- timestamp: ['0'],
108
- rvm: ['0', '0.5'],
109
- inject_passwords: ['0'],
110
- inject_env_var: ['0'],
111
- artifactory: ['0'],
112
- maven3artifactory: ['0'],
113
- nodejs: ['0'],
114
- xvfb: ['0']
115
- }
116
- registry = JenkinsPipelineBuilder.registry.registry
117
- expect(registry[:job][:wrappers].size).to eq wrappers.size
118
- wrappers.each do |wrapper, versions|
119
- expect(registry[:job][:wrappers]).to have_key wrapper
120
-
121
- versions.each do |version|
122
- expect(registry[:job][:wrappers][wrapper]).to have_min_version version
123
- end
124
- end
125
- end
126
16
  end
17
+
127
18
  describe '#initialize' do
128
19
  end
129
20
 
@@ -23,3 +23,15 @@ RSpec.configure do |config|
23
23
  c.syntax = :expect
24
24
  end
25
25
  end
26
+
27
+ RSpec::Matchers.define :have_registered_versions do |versions|
28
+ match do |set|
29
+ @set = set
30
+ @registered_versions = set.versions.keys.map(&:version)
31
+ @registered_versions.sort == versions.sort
32
+ end
33
+
34
+ failure_message do
35
+ "Expected #{@set.name} to have registered versions #{versions}. Got #{@registered_versions}"
36
+ end
37
+ end
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.10.16
4
+ version: 0.11.0
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-04-16 00:00:00.000000000 Z
12
+ date: 2015-04-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -354,6 +354,13 @@ files:
354
354
  - lib/jenkins_pipeline_builder/extension_set.rb
355
355
  - lib/jenkins_pipeline_builder/extensions.rb
356
356
  - lib/jenkins_pipeline_builder/extensions/builders.rb
357
+ - lib/jenkins_pipeline_builder/extensions/helpers/builders/blocking_downstream_helper.rb
358
+ - lib/jenkins_pipeline_builder/extensions/helpers/builders/maven3_helper.rb
359
+ - lib/jenkins_pipeline_builder/extensions/helpers/extension_helper.rb
360
+ - lib/jenkins_pipeline_builder/extensions/helpers/job_attributes/parameters_helper.rb
361
+ - lib/jenkins_pipeline_builder/extensions/helpers/publishers/cobertura_report_helper.rb
362
+ - lib/jenkins_pipeline_builder/extensions/helpers/publishers/email_ext_helper.rb
363
+ - lib/jenkins_pipeline_builder/extensions/helpers/triggers/upstream_helper.rb
357
364
  - lib/jenkins_pipeline_builder/extensions/job_attributes.rb
358
365
  - lib/jenkins_pipeline_builder/extensions/publishers.rb
359
366
  - lib/jenkins_pipeline_builder/extensions/triggers.rb
@@ -362,6 +369,7 @@ files:
362
369
  - lib/jenkins_pipeline_builder/job.rb
363
370
  - lib/jenkins_pipeline_builder/job_collection.rb
364
371
  - lib/jenkins_pipeline_builder/module_registry.rb
372
+ - lib/jenkins_pipeline_builder/project.rb
365
373
  - lib/jenkins_pipeline_builder/pull_request.rb
366
374
  - lib/jenkins_pipeline_builder/pull_request_generator.rb
367
375
  - lib/jenkins_pipeline_builder/remote_dependencies.rb
@@ -373,9 +381,13 @@ files:
373
381
  - pipeline/project.yaml
374
382
  - spec/lib/jenkins_pipeline_builder/cli/helper_spec.rb
375
383
  - spec/lib/jenkins_pipeline_builder/compiler_spec.rb
384
+ - spec/lib/jenkins_pipeline_builder/extension_dsl_spec.rb
385
+ - spec/lib/jenkins_pipeline_builder/extension_set_spec.rb
376
386
  - spec/lib/jenkins_pipeline_builder/extensions/builders_spec.rb
377
387
  - spec/lib/jenkins_pipeline_builder/extensions/job_attributes_spec.rb
378
388
  - spec/lib/jenkins_pipeline_builder/extensions/publishers_spec.rb
389
+ - spec/lib/jenkins_pipeline_builder/extensions/registered_spec.rb
390
+ - spec/lib/jenkins_pipeline_builder/extensions/triggers_spec.rb
379
391
  - spec/lib/jenkins_pipeline_builder/extensions/wrappers_spec.rb
380
392
  - spec/lib/jenkins_pipeline_builder/extensions_spec.rb
381
393
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/local_override/all_local/10.yaml
@@ -401,12 +413,15 @@ files:
401
413
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/test_json_files/view.json
402
414
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/test_yaml_files/project.yaml
403
415
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/test_yaml_files/view.yaml
416
+ - spec/lib/jenkins_pipeline_builder/fixtures/job_collection/extensions/extension.rb
417
+ - spec/lib/jenkins_pipeline_builder/fixtures/job_collection/extensions/helpers/my_test_thing_helper.rb
404
418
  - spec/lib/jenkins_pipeline_builder/fixtures/sample_creds.json
405
419
  - spec/lib/jenkins_pipeline_builder/fixtures/sample_creds.yaml
406
420
  - spec/lib/jenkins_pipeline_builder/fixtures/view_test/duplicate_view.yaml
407
421
  - spec/lib/jenkins_pipeline_builder/fixtures/view_test/parent_view.yaml
408
422
  - spec/lib/jenkins_pipeline_builder/fixtures/view_test/regular_view.yaml
409
423
  - spec/lib/jenkins_pipeline_builder/generator_spec.rb
424
+ - spec/lib/jenkins_pipeline_builder/job_collection_spec.rb
410
425
  - spec/lib/jenkins_pipeline_builder/job_spec.rb
411
426
  - spec/lib/jenkins_pipeline_builder/module_registry_spec.rb
412
427
  - spec/lib/jenkins_pipeline_builder/pull_request_generator_spec.rb
@@ -442,9 +457,13 @@ summary: This gem is will boostrap your Jenkins pipelines
442
457
  test_files:
443
458
  - spec/lib/jenkins_pipeline_builder/cli/helper_spec.rb
444
459
  - spec/lib/jenkins_pipeline_builder/compiler_spec.rb
460
+ - spec/lib/jenkins_pipeline_builder/extension_dsl_spec.rb
461
+ - spec/lib/jenkins_pipeline_builder/extension_set_spec.rb
445
462
  - spec/lib/jenkins_pipeline_builder/extensions/builders_spec.rb
446
463
  - spec/lib/jenkins_pipeline_builder/extensions/job_attributes_spec.rb
447
464
  - spec/lib/jenkins_pipeline_builder/extensions/publishers_spec.rb
465
+ - spec/lib/jenkins_pipeline_builder/extensions/registered_spec.rb
466
+ - spec/lib/jenkins_pipeline_builder/extensions/triggers_spec.rb
448
467
  - spec/lib/jenkins_pipeline_builder/extensions/wrappers_spec.rb
449
468
  - spec/lib/jenkins_pipeline_builder/extensions_spec.rb
450
469
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/local_override/all_local/10.yaml
@@ -470,12 +489,15 @@ test_files:
470
489
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/test_json_files/view.json
471
490
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/test_yaml_files/project.yaml
472
491
  - spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/test_yaml_files/view.yaml
492
+ - spec/lib/jenkins_pipeline_builder/fixtures/job_collection/extensions/extension.rb
493
+ - spec/lib/jenkins_pipeline_builder/fixtures/job_collection/extensions/helpers/my_test_thing_helper.rb
473
494
  - spec/lib/jenkins_pipeline_builder/fixtures/sample_creds.json
474
495
  - spec/lib/jenkins_pipeline_builder/fixtures/sample_creds.yaml
475
496
  - spec/lib/jenkins_pipeline_builder/fixtures/view_test/duplicate_view.yaml
476
497
  - spec/lib/jenkins_pipeline_builder/fixtures/view_test/parent_view.yaml
477
498
  - spec/lib/jenkins_pipeline_builder/fixtures/view_test/regular_view.yaml
478
499
  - spec/lib/jenkins_pipeline_builder/generator_spec.rb
500
+ - spec/lib/jenkins_pipeline_builder/job_collection_spec.rb
479
501
  - spec/lib/jenkins_pipeline_builder/job_spec.rb
480
502
  - spec/lib/jenkins_pipeline_builder/module_registry_spec.rb
481
503
  - spec/lib/jenkins_pipeline_builder/pull_request_generator_spec.rb