jenkins_pipeline_builder 0.7.6 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -4
- data/README.md +52 -1
- data/lib/jenkins_pipeline_builder/extensions.rb +31 -1
- data/lib/jenkins_pipeline_builder/extensions/job_attributes.rb +97 -67
- data/lib/jenkins_pipeline_builder/extensions/wrappers.rb +18 -13
- data/lib/jenkins_pipeline_builder/generator.rb +1 -1
- data/lib/jenkins_pipeline_builder/module_registry.rb +18 -1
- data/lib/jenkins_pipeline_builder/version.rb +1 -1
- data/spec/lib/jenkins_pipeline_builder/extensions/job_attributes_spec.rb +11 -1
- data/spec/lib/jenkins_pipeline_builder/extensions/wrappers_spec.rb +62 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ca43becc8a1b41d7db4b5eed240b85f9924ab91
|
4
|
+
data.tar.gz: cb8dc5088ab19da3cde68b8b09782d8e002b662b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 550a353d6674f1efd02be4a10bcb242684ae0e0e2675b419deabdc5b68cbfcb9923d87159f273b02f540a9a572dae9d4c34e3ffbf761970209fe7ed3f321d70a
|
7
|
+
data.tar.gz: 7e2e5a8ef0954ec7b947444bae305a24e965439c369e9d9a96af10ec3e4cf74aaa836a79a07aa034c45aa4654e0b02dc73763e95cfc1c2cb635302aabd9b1f20
|
data/.rubocop.yml
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
#######
|
9
9
|
# WIP
|
10
|
-
|
10
|
+
Metrics/CyclomaticComplexity:
|
11
11
|
Max: 9
|
12
12
|
|
13
13
|
Metrics/PerceivedComplexity:
|
@@ -16,14 +16,14 @@ Metrics/PerceivedComplexity:
|
|
16
16
|
########
|
17
17
|
# Fix these later
|
18
18
|
# Configuration parameters: CountComments.
|
19
|
-
|
19
|
+
Metrics/ClassLength:
|
20
20
|
#Enabled: false
|
21
21
|
Max: 500
|
22
22
|
|
23
23
|
#######
|
24
24
|
# Finalized settings
|
25
25
|
|
26
|
-
|
26
|
+
Metrics/LineLength:
|
27
27
|
Max: 120
|
28
28
|
Exclude:
|
29
29
|
- 'spec/lib/jenkins_pipeline_builder/compiler_spec.rb'
|
@@ -32,7 +32,7 @@ Style/LineLength:
|
|
32
32
|
- 'lib/jenkins_pipeline_builder/extensions/*'
|
33
33
|
|
34
34
|
# Configuration parameters: CountComments.
|
35
|
-
|
35
|
+
Metrics/MethodLength:
|
36
36
|
Max: 25
|
37
37
|
|
38
38
|
Style/Documentation:
|
data/README.md
CHANGED
@@ -73,7 +73,6 @@ Now you ready to bootstrap a pipeline:
|
|
73
73
|
generate pipeline -c config/login.yml bootstrap ./pipeline
|
74
74
|
|
75
75
|
NOTE: you can run the pipeline in NOOP (debug-only) mode by addind -d parameter, like:
|
76
|
-
|
77
76
|
generate pipeline -d -c config/login.yml bootstrap ./pipeline
|
78
77
|
|
79
78
|
The command comes with fairly extensive help. For example you can list all of the registered extension types with `generate list` and a list of all extensions of a type with `generate list type`
|
@@ -359,6 +358,7 @@ publisher do
|
|
359
358
|
min_version '0.4'
|
360
359
|
jenkins_name "Jenkins UI Name"
|
361
360
|
description "Description of this feature"
|
361
|
+
params[:thing, :value]
|
362
362
|
|
363
363
|
xml do |params, xml|
|
364
364
|
send("new_element") do
|
@@ -371,6 +371,57 @@ publisher do
|
|
371
371
|
end
|
372
372
|
```
|
373
373
|
|
374
|
+
You can also declare multiple versions of an extension. Some plugins have breaking xml changes between versions. Simply declare a version block with the minimum required version and then declare your xml, before and after blocks inside that version.
|
375
|
+
|
376
|
+
```ruby
|
377
|
+
publisher do
|
378
|
+
name :yaml_name
|
379
|
+
plugin_id 123
|
380
|
+
min_version '0.4'
|
381
|
+
jenkins_name "Jenkins UI Name"
|
382
|
+
description "Description of this feature"
|
383
|
+
|
384
|
+
version '0' do
|
385
|
+
before do
|
386
|
+
# preprocessing here
|
387
|
+
end
|
388
|
+
|
389
|
+
after do
|
390
|
+
# post processing here
|
391
|
+
end
|
392
|
+
|
393
|
+
xml do |params, xml|
|
394
|
+
send("new.element") do
|
395
|
+
property params[:value]
|
396
|
+
if params[:thing]
|
397
|
+
thing 'true'
|
398
|
+
end
|
399
|
+
end
|
400
|
+
end
|
401
|
+
end
|
402
|
+
|
403
|
+
version '1.0' do
|
404
|
+
before do
|
405
|
+
# preprocessing here
|
406
|
+
end
|
407
|
+
|
408
|
+
after do
|
409
|
+
# post processing here
|
410
|
+
end
|
411
|
+
|
412
|
+
xml do |params, xml|
|
413
|
+
send("different.element") do
|
414
|
+
property params[:value]
|
415
|
+
if params[:thing]
|
416
|
+
thing 'true'
|
417
|
+
end
|
418
|
+
end
|
419
|
+
end
|
420
|
+
end
|
421
|
+
end
|
422
|
+
```
|
423
|
+
|
424
|
+
|
374
425
|
Finally, you can add the new DSL in your YAML:
|
375
426
|
|
376
427
|
```yaml
|
@@ -139,7 +139,19 @@ module JenkinsPipelineBuilder
|
|
139
139
|
blocks.merge other_set.blocks
|
140
140
|
end
|
141
141
|
|
142
|
+
def parameters(params)
|
143
|
+
version = @min_version || '0'
|
144
|
+
|
145
|
+
blocks[version] = {} unless blocks[version]
|
146
|
+
blocks[version][:parameters] = params
|
147
|
+
end
|
148
|
+
|
142
149
|
def xml(path: false, version: '0', &block)
|
150
|
+
if @min_version
|
151
|
+
version = @min_version
|
152
|
+
elsif version != '0'
|
153
|
+
deprecation_warning(settings[:name], 'xml')
|
154
|
+
end
|
143
155
|
unless block
|
144
156
|
fail "no block found for version #{version}" unless blocks.key version
|
145
157
|
return blocks[version][:block]
|
@@ -151,8 +163,19 @@ module JenkinsPipelineBuilder
|
|
151
163
|
end
|
152
164
|
end
|
153
165
|
|
166
|
+
def version(ver, &block)
|
167
|
+
@min_version = ver
|
168
|
+
yield block
|
169
|
+
end
|
170
|
+
|
154
171
|
[:after, :before].each do |method_name|
|
155
172
|
define_method method_name do |version: '0', &block|
|
173
|
+
if @min_version
|
174
|
+
version = @min_version
|
175
|
+
elsif version != '0'
|
176
|
+
deprecation_warning(settings[:name], method_name)
|
177
|
+
end
|
178
|
+
|
156
179
|
return instance_variable_get(method_name) unless block
|
157
180
|
blocks[version] = {} unless blocks[version]
|
158
181
|
blocks[version][method_name] = block
|
@@ -172,6 +195,12 @@ module JenkinsPipelineBuilder
|
|
172
195
|
end
|
173
196
|
errors
|
174
197
|
end
|
198
|
+
|
199
|
+
private
|
200
|
+
|
201
|
+
def deprecation_warning(name, block)
|
202
|
+
puts "WARNING: #{name} set the version in the #{block} block, this is deprecated. Please use a version block."
|
203
|
+
end
|
175
204
|
end
|
176
205
|
end
|
177
206
|
|
@@ -188,7 +217,8 @@ module JenkinsPipelineBuilder
|
|
188
217
|
type: false,
|
189
218
|
before: false,
|
190
219
|
after: false,
|
191
|
-
xml: false
|
220
|
+
xml: false,
|
221
|
+
parameters: []
|
192
222
|
}
|
193
223
|
EXT_METHODS.keys.each do |method_name|
|
194
224
|
define_method method_name do |value = nil|
|
@@ -60,88 +60,118 @@ job_attribute do
|
|
60
60
|
jenkins_name "Git (inside 'Source Code Management')"
|
61
61
|
announced false
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
63
|
+
version '0' do
|
64
|
+
parameters [
|
65
|
+
:remote_name,
|
66
|
+
:refspec,
|
67
|
+
:local_branch,
|
68
|
+
:recursive_update,
|
69
|
+
:wipe_workspace,
|
70
|
+
:excluded_users,
|
71
|
+
:skip_tag,
|
72
|
+
:remote_url,
|
73
|
+
:excluded_regions,
|
74
|
+
:included_regions
|
75
|
+
]
|
76
|
+
|
77
|
+
# XML preprocessing
|
78
|
+
# TODO: Actually figure out how to merge using the builder DSL
|
79
|
+
# This delete the things we are going to add later is pretty crappy
|
80
|
+
# Alternately don't use/tweak the xml the api client generates
|
81
|
+
# (which is where I assume this is coming from)
|
82
|
+
before do |params|
|
83
|
+
xpath('//scm/localBranch').remove if params[:local_branch]
|
84
|
+
xpath('//scm/recursiveSubmodules').remove if params[:recursive_update]
|
85
|
+
xpath('//scm/wipeOutWorkspace').remove if params[:wipe_workspace]
|
86
|
+
xpath('//scm/excludedUsers').remove if params[:excluded_users]
|
87
|
+
if params[:remote_name] || params[:refspec]
|
88
|
+
remote_url = xpath('//scm/userRemoteConfigs/hudson.plugins.git.UserRemoteConfig/url').first
|
89
|
+
params[:remote_url] = remote_url.content if remote_url
|
90
|
+
xpath('//scm/userRemoteConfigs').remove
|
91
|
+
end
|
92
|
+
xpath('//scm/skipTag').remove if params[:skip_tag]
|
93
|
+
xpath('//scm/excludedRegions').remove if params[:excluded_regions]
|
94
|
+
xpath('//scm/includedRegions').remove if params[:included_regions]
|
77
95
|
end
|
78
|
-
xpath('//scm/skipTag').remove if params[:skip_tag]
|
79
|
-
xpath('//scm/excludedRegions').remove if params[:excluded_regions]
|
80
|
-
xpath('//scm/includedRegions').remove if params[:included_regions]
|
81
|
-
end
|
82
96
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
params[:
|
87
|
-
|
97
|
+
xml path: '//scm' do |params|
|
98
|
+
localBranch params[:local_branch] if params[:local_branch]
|
99
|
+
recursiveSubmodules params[:recursive_update] if params[:recursive_update]
|
100
|
+
wipeOutWorkspace params[:wipe_workspace] if params[:wipe_workspace]
|
101
|
+
excludedUsers params[:excluded_users] if params[:excluded_users]
|
102
|
+
if params[:remote_name] || params[:refspec]
|
103
|
+
userRemoteConfigs do
|
104
|
+
send('hudson.plugins.git.UserRemoteConfig') do
|
105
|
+
name params[:remote_name] if params[:remote_name]
|
106
|
+
refspec params[:refspec] if params[:refspec]
|
107
|
+
url params[:remote_url] if params[:remote_url]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
skipTag params[:skip_tag] if params[:skip_tag]
|
112
|
+
excludedRegions params[:excluded_regions] if params[:excluded_regions]
|
113
|
+
includedRegions params[:included_regions] if params[:included_regions]
|
88
114
|
end
|
89
115
|
end
|
90
116
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
117
|
+
version '2.0' do
|
118
|
+
parameters [
|
119
|
+
:credentials_id,
|
120
|
+
:excluded_regions,
|
121
|
+
:excluded_users,
|
122
|
+
:included_regions,
|
123
|
+
:local_branch,
|
124
|
+
:recursive_update,
|
125
|
+
:refspec,
|
126
|
+
:remote_name,
|
127
|
+
:remote_url,
|
128
|
+
:wipe_workspace
|
129
|
+
]
|
130
|
+
|
131
|
+
before do |params|
|
132
|
+
if params[:remote_name] || params[:refspec]
|
133
|
+
remote_url = xpath('//scm/userRemoteConfigs/hudson.plugins.git.UserRemoteConfig/url').first
|
134
|
+
params[:remote_url] = remote_url.content if remote_url
|
135
|
+
xpath('//scm/userRemoteConfigs').remove
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
xml path: '//scm' do |params|
|
140
|
+
configVersion 2
|
97
141
|
userRemoteConfigs do
|
98
142
|
send('hudson.plugins.git.UserRemoteConfig') do
|
99
143
|
name params[:remote_name] if params[:remote_name]
|
100
144
|
refspec params[:refspec] if params[:refspec]
|
101
145
|
url params[:remote_url] if params[:remote_url]
|
146
|
+
credentialsId params[:credentials_id] if params[:credentials_id]
|
102
147
|
end
|
103
148
|
end
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
userRemoteConfigs do
|
113
|
-
send('hudson.plugins.git.UserRemoteConfig') do
|
114
|
-
name params[:remote_name] if params[:remote_name]
|
115
|
-
refspec params[:refspec] if params[:refspec]
|
116
|
-
url params[:remote_url] if params[:remote_url]
|
117
|
-
credentialsId params[:credentials_id] if params[:credentials_id]
|
118
|
-
end
|
119
|
-
end
|
120
|
-
doGenerateSubmoduleConfigurations false
|
121
|
-
submoduleCfg
|
122
|
-
extensions do
|
123
|
-
send('hudson.plugins.git.extensions.impl.WipeWorkspace') if params[:wipe_workspace]
|
124
|
-
if params[:local_branch]
|
125
|
-
send('hudson.plugins.git.extensions.impl.LocalWorkspace') do
|
126
|
-
localBranch params[:local_branch]
|
149
|
+
doGenerateSubmoduleConfigurations false
|
150
|
+
submoduleCfg
|
151
|
+
extensions do
|
152
|
+
send('hudson.plugins.git.extensions.impl.WipeWorkspace') if params[:wipe_workspace]
|
153
|
+
if params[:local_branch]
|
154
|
+
send('hudson.plugins.git.extensions.impl.LocalWorkspace') do
|
155
|
+
localBranch params[:local_branch]
|
156
|
+
end
|
127
157
|
end
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
158
|
+
if params[:recursive_update]
|
159
|
+
send('hudson.plugins.git.extensions.impl.SubmoduleOption') do
|
160
|
+
disableSubmodules false
|
161
|
+
recursiveSubmodules true
|
162
|
+
trackingSubmodules false
|
163
|
+
end
|
134
164
|
end
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
165
|
+
if params[:excluded_users]
|
166
|
+
send('hudson.plugins.git.extensions.impl.UserExclusion') do
|
167
|
+
excludedUser params[:excluded_users]
|
168
|
+
end
|
139
169
|
end
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
170
|
+
if params[:included_regions] || params[:excluded_regions]
|
171
|
+
send('hudson.plugins.git.extensions.impl.PathRestrictions') do
|
172
|
+
includedRegions params[:included_regions] if params[:included_regions]
|
173
|
+
excludedRegions params[:excluded_regions] if params[:excluded_regions]
|
174
|
+
end
|
145
175
|
end
|
146
176
|
end
|
147
177
|
end
|
@@ -26,6 +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
|
xml do |_|
|
30
31
|
send('hudson.plugins.ansicolor.AnsiColorBuildWrapper') do
|
31
32
|
colorMapName 'xterm'
|
@@ -53,26 +54,30 @@ wrapper do
|
|
53
54
|
announced false
|
54
55
|
description 'rvm plugin'
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
send('ruby-object'
|
59
|
-
|
60
|
-
|
57
|
+
version '0.5' do
|
58
|
+
xml do |wrapper|
|
59
|
+
send('ruby-proxy-object') do
|
60
|
+
send('ruby-object', 'ruby-class' => 'Jenkins::Tasks::BuildWrapperProxy', 'pluginid' => 'rvm') do
|
61
|
+
object('ruby-class' => 'RvmWrapper', 'pluginid' => 'rvm') do
|
62
|
+
impl('pluginid' => 'rvm', 'ruby-class' => 'String') { text wrapper }
|
63
|
+
end
|
64
|
+
pluginid(:pluginid => 'rvm', 'ruby-class' => 'String') { text 'rvm' }
|
61
65
|
end
|
62
|
-
pluginid(:pluginid => 'rvm', 'ruby-class' => 'String') { text 'rvm' }
|
63
66
|
end
|
64
67
|
end
|
65
68
|
end
|
66
69
|
|
67
|
-
|
68
|
-
|
69
|
-
send('ruby-object'
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
version '0' do
|
71
|
+
xml do |wrapper|
|
72
|
+
send('ruby-proxy-object') do
|
73
|
+
send('ruby-object', 'ruby-class' => 'Jenkins::Plugin::Proxies::BuildWrapper', 'pluginid' => 'rvm') do
|
74
|
+
object('ruby-class' => 'RvmWrapper', 'pluginid' => 'rvm') do
|
75
|
+
impl('pluginid' => 'rvm', 'ruby-class' => 'String') do
|
76
|
+
text wrapper
|
77
|
+
end
|
73
78
|
end
|
79
|
+
pluginid(:pluginid => 'rvm', 'ruby-class' => 'String') { text 'rvm' }
|
74
80
|
end
|
75
|
-
pluginid(:pluginid => 'rvm', 'ruby-class' => 'String') { text 'rvm' }
|
76
81
|
end
|
77
82
|
end
|
78
83
|
end
|
@@ -523,7 +523,7 @@ module JenkinsPipelineBuilder
|
|
523
523
|
end
|
524
524
|
|
525
525
|
xml = client.job.build_freestyle_config(params)
|
526
|
-
n_xml = Nokogiri::XML(xml)
|
526
|
+
n_xml = Nokogiri::XML(xml, &:noblanks)
|
527
527
|
|
528
528
|
logger.debug 'Loading the required modules'
|
529
529
|
@module_registry.traverse_registry_path('job', params, n_xml)
|
@@ -93,7 +93,8 @@ module JenkinsPipelineBuilder
|
|
93
93
|
if reg_value.is_a? ExtensionSet
|
94
94
|
ext = reg_value.extension
|
95
95
|
logger.debug "Using #{ext.type} #{ext.name} version #{ext.min_version}"
|
96
|
-
execute_extension ext, value, n_xml
|
96
|
+
success = execute_extension ext, value, n_xml
|
97
|
+
fail 'Encountered errors compiling the xml' unless success
|
97
98
|
elsif value.is_a? Hash
|
98
99
|
traverse_registry reg_value, value, n_xml, true
|
99
100
|
elsif value.is_a? Array
|
@@ -105,12 +106,28 @@ module JenkinsPipelineBuilder
|
|
105
106
|
end
|
106
107
|
|
107
108
|
def execute_extension(extension, value, n_xml)
|
109
|
+
errors = []
|
110
|
+
params = extension.parameters
|
111
|
+
if params == false || params.any?
|
112
|
+
if value.is_a? Hash
|
113
|
+
value.each_key do |key|
|
114
|
+
next if params && params.include?(key)
|
115
|
+
errors << "Extension #{extension.name} does not support parameter #{key}"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
errors.each do |error|
|
120
|
+
logger.error error
|
121
|
+
end
|
122
|
+
return false if errors.any?
|
123
|
+
|
108
124
|
n_builders = n_xml.xpath(extension.path).first
|
109
125
|
n_builders.instance_exec(value, &extension.before) if extension.before
|
110
126
|
Nokogiri::XML::Builder.with(n_builders) do |xml|
|
111
127
|
xml.instance_exec value, &extension.xml
|
112
128
|
end
|
113
129
|
n_builders.instance_exec(value, &extension.after) if extension.after
|
130
|
+
true
|
114
131
|
end
|
115
132
|
end
|
116
133
|
end
|
@@ -91,7 +91,12 @@ describe 'job_attributes' do
|
|
91
91
|
recursive_update: true,
|
92
92
|
excluded_users: :exclude_me,
|
93
93
|
included_regions: :included_region,
|
94
|
-
excluded_regions: :excluded_region
|
94
|
+
excluded_regions: :excluded_region,
|
95
|
+
wipe_workspace: true,
|
96
|
+
remote_name: :foo,
|
97
|
+
refspec: :refspec,
|
98
|
+
remote_url: :remote_url,
|
99
|
+
credentials_id: :creds
|
95
100
|
},
|
96
101
|
scm_url: 'http://foo.com'
|
97
102
|
}
|
@@ -107,6 +112,10 @@ describe 'job_attributes' do
|
|
107
112
|
expect(scm_config.css('excludedUser').first).to be_truthy
|
108
113
|
expect(scm_config.css('includedRegions').first).to be_truthy
|
109
114
|
expect(scm_config.css('excludedRegions').first).to be_truthy
|
115
|
+
expect(scm_config.css('credentialsId').first).to be_truthy
|
116
|
+
expect(
|
117
|
+
scm_config.xpath('//scm/extensions/hudson.plugins.git.extensions.impl.WipeWorkspace').first
|
118
|
+
).to_not be_nil
|
110
119
|
|
111
120
|
expect(scm_config.css('disableSubmodules').first.content).to eq 'false'
|
112
121
|
expect(scm_config.css('recursiveSubmodules').first.content).to eq 'true'
|
@@ -115,6 +124,7 @@ describe 'job_attributes' do
|
|
115
124
|
expect(scm_config.css('excludedUser').first.content).to eq 'exclude_me'
|
116
125
|
expect(scm_config.css('includedRegions').first.content).to eq 'included_region'
|
117
126
|
expect(scm_config.css('excludedRegions').first.content).to eq 'excluded_region'
|
127
|
+
expect(scm_config.css('credentialsId').first.content).to eq 'creds'
|
118
128
|
end
|
119
129
|
end
|
120
130
|
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe 'wrappers' do
|
4
|
+
after :each do
|
5
|
+
JenkinsPipelineBuilder.registry.clear_versions
|
6
|
+
end
|
7
|
+
|
8
|
+
before :all do
|
9
|
+
JenkinsPipelineBuilder.credentials = {
|
10
|
+
server_ip: '127.0.0.1',
|
11
|
+
server_port: 8080,
|
12
|
+
username: 'username',
|
13
|
+
password: 'password',
|
14
|
+
log_location: '/dev/null'
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
before :each do
|
19
|
+
builder = Nokogiri::XML::Builder.new { |xml| xml.buildWrappers }
|
20
|
+
@n_xml = builder.doc
|
21
|
+
end
|
22
|
+
|
23
|
+
after :each do |example|
|
24
|
+
name = example.description.gsub ' ', '_'
|
25
|
+
File.open("./out/xml/wrapper_#{name}.xml", 'w') { |f| @n_xml.write_xml_to f }
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'ansicolor' do
|
29
|
+
before :each do
|
30
|
+
JenkinsPipelineBuilder.registry.registry[:job][:wrappers][:ansicolor].installed_version = '0.0'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'generates correct xml' do
|
34
|
+
JenkinsPipelineBuilder.registry.traverse_registry_path('job', { wrappers: { ansicolor: true } }, @n_xml)
|
35
|
+
|
36
|
+
node = @n_xml.root.xpath('//buildWrappers/hudson.plugins.ansicolor.AnsiColorBuildWrapper')
|
37
|
+
expect(node.first).to be_truthy
|
38
|
+
expect(node.first.content).to eq 'xterm'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'fails parameters are passed' do
|
42
|
+
params = { wrappers: { ansicolor: { config: false } } }
|
43
|
+
expect do
|
44
|
+
JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
|
45
|
+
end.to raise_error
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'timestamp' do
|
50
|
+
before :each do
|
51
|
+
JenkinsPipelineBuilder.registry.registry[:job][:wrappers][:timestamp].installed_version = '0.0'
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'generates correct xml' do
|
55
|
+
JenkinsPipelineBuilder.registry.traverse_registry_path('job', { wrappers: { timestamp: true } }, @n_xml)
|
56
|
+
|
57
|
+
node = @n_xml.root.xpath('//buildWrappers/hudson.plugins.timestamper.TimestamperBuildWrapper')
|
58
|
+
expect(node.first).to_not be_nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
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.
|
4
|
+
version: 0.8.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: 2014-09-
|
12
|
+
date: 2014-09-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -359,6 +359,7 @@ files:
|
|
359
359
|
- spec/lib/jenkins_pipeline_builder/extensions/builders_spec.rb
|
360
360
|
- spec/lib/jenkins_pipeline_builder/extensions/job_attributes_spec.rb
|
361
361
|
- spec/lib/jenkins_pipeline_builder/extensions/publishers_spec.rb
|
362
|
+
- spec/lib/jenkins_pipeline_builder/extensions/wrappers_spec.rb
|
362
363
|
- spec/lib/jenkins_pipeline_builder/extensions_spec.rb
|
363
364
|
- spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/PullRequest-10-SampleJob.yaml
|
364
365
|
- spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/PullRequest-40-PullRequestGenerator.yaml
|
@@ -410,6 +411,7 @@ test_files:
|
|
410
411
|
- spec/lib/jenkins_pipeline_builder/extensions/builders_spec.rb
|
411
412
|
- spec/lib/jenkins_pipeline_builder/extensions/job_attributes_spec.rb
|
412
413
|
- spec/lib/jenkins_pipeline_builder/extensions/publishers_spec.rb
|
414
|
+
- spec/lib/jenkins_pipeline_builder/extensions/wrappers_spec.rb
|
413
415
|
- spec/lib/jenkins_pipeline_builder/extensions_spec.rb
|
414
416
|
- spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/PullRequest-10-SampleJob.yaml
|
415
417
|
- spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/PullRequest-40-PullRequestGenerator.yaml
|