jenkins_pipeline_builder 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +28 -43
- data/{spec/unit_tests/spec_helper.rb → .simplecov} +2 -15
- data/README.md +66 -11
- data/Rakefile +1 -25
- data/bin/generate +0 -1
- data/jenkins_pipeline_builder.gemspec +6 -6
- data/lib/jenkins_pipeline_builder.rb +14 -8
- data/lib/jenkins_pipeline_builder/builders.rb +207 -155
- data/lib/jenkins_pipeline_builder/cli/base.rb +1 -1
- data/lib/jenkins_pipeline_builder/cli/describe.rb +12 -8
- data/lib/jenkins_pipeline_builder/cli/list.rb +7 -7
- data/lib/jenkins_pipeline_builder/compiler.rb +62 -49
- data/lib/jenkins_pipeline_builder/extensions.rb +108 -0
- data/lib/jenkins_pipeline_builder/generator.rb +209 -160
- data/lib/jenkins_pipeline_builder/job_builder.rb +174 -105
- data/lib/jenkins_pipeline_builder/module_registry.rb +43 -59
- data/lib/jenkins_pipeline_builder/publishers.rb +166 -93
- data/lib/jenkins_pipeline_builder/pull_request.rb +7 -7
- data/lib/jenkins_pipeline_builder/triggers.rb +63 -40
- data/lib/jenkins_pipeline_builder/utils.rb +10 -10
- data/lib/jenkins_pipeline_builder/version.rb +1 -1
- data/lib/jenkins_pipeline_builder/view.rb +94 -123
- data/lib/jenkins_pipeline_builder/wrappers.rb +163 -96
- data/spec/lib/jenkins_pipeline_builder/compiler_spec.rb +31 -0
- data/spec/lib/jenkins_pipeline_builder/extensions_spec.rb +145 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/PullRequest-10-SampleJob.yaml +2 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/PullRequest-40-PullRequestGenerator.yaml +12 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/project.yaml +12 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/sample_pipeline/SamplePipeline-10-Commit.yaml +3 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/sample_pipeline/SamplePipeline-20-Acceptance.yaml +3 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/sample_pipeline/SamplePipeline-30-Release.yaml +3 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/sample_pipeline/project.yaml +12 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/sample_pipeline/view.yaml +5 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/template_pipeline/jobs.tar.gz +0 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/template_pipeline/project.yaml +15 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/test_job.xml +48 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/view_test/duplicate_view.yaml +4 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/view_test/parent_view.yaml +9 -0
- data/spec/lib/jenkins_pipeline_builder/fixtures/view_test/regular_view.yaml +5 -0
- data/spec/lib/jenkins_pipeline_builder/generator_spec.rb +165 -0
- data/spec/lib/jenkins_pipeline_builder/module_registry_spec.rb +147 -0
- data/spec/lib/jenkins_pipeline_builder/pull_request_spec.rb +47 -0
- data/spec/lib/jenkins_pipeline_builder/spec_helper.rb +25 -0
- data/spec/lib/jenkins_pipeline_builder/utils_spec.rb +22 -0
- data/spec/lib/jenkins_pipeline_builder/view_spec.rb +54 -0
- metadata +54 -136
- data/lib/jenkins_pipeline_builder/extendable.rb +0 -42
- data/lib/jenkins_pipeline_builder/xml_helper.rb +0 -40
- data/spec/func_tests/spec_helper.rb +0 -18
- data/spec/func_tests/view_spec.rb +0 -90
- data/spec/unit_tests/compiler_spec.rb +0 -20
- data/spec/unit_tests/fixtures/files/Job-Build-Flow.xml +0 -57
- data/spec/unit_tests/fixtures/files/Job-Build-Flow.yaml +0 -22
- data/spec/unit_tests/fixtures/files/Job-Build-Maven.xml +0 -129
- data/spec/unit_tests/fixtures/files/Job-Build-Maven.yaml +0 -31
- data/spec/unit_tests/fixtures/files/Job-DSL.yaml +0 -14
- data/spec/unit_tests/fixtures/files/Job-DSL1.xml +0 -27
- data/spec/unit_tests/fixtures/files/Job-DSL2.xml +0 -25
- data/spec/unit_tests/fixtures/files/Job-Gem-Build.xml +0 -142
- data/spec/unit_tests/fixtures/files/Job-Gem-Build.yaml +0 -43
- data/spec/unit_tests/fixtures/files/Job-Generate-From-Template.xml +0 -32
- data/spec/unit_tests/fixtures/files/Job-Generate-From-Template.yaml +0 -8
- data/spec/unit_tests/fixtures/files/Job-Multi-Project.xml +0 -134
- data/spec/unit_tests/fixtures/files/Job-Multi-Project.yaml +0 -49
- data/spec/unit_tests/fixtures/files/archive_artifact.xml +0 -23
- data/spec/unit_tests/fixtures/files/archive_artifact.yaml +0 -5
- data/spec/unit_tests/fixtures/files/choice_parameter.xml +0 -39
- data/spec/unit_tests/fixtures/files/choice_parameter.yaml +0 -14
- data/spec/unit_tests/fixtures/files/concurrent_build.xml +0 -17
- data/spec/unit_tests/fixtures/files/concurrent_build.yaml +0 -4
- data/spec/unit_tests/fixtures/files/copy_artifact.xml +0 -30
- data/spec/unit_tests/fixtures/files/copy_artifact.yaml +0 -14
- data/spec/unit_tests/fixtures/files/discard_old.xml +0 -17
- data/spec/unit_tests/fixtures/files/discard_old.yaml +0 -8
- data/spec/unit_tests/fixtures/files/downstream.xml +0 -36
- data/spec/unit_tests/fixtures/files/downstream.yaml +0 -13
- data/spec/unit_tests/fixtures/files/downstream_blocking.xml +0 -19
- data/spec/unit_tests/fixtures/files/downstream_blocking.yaml +0 -15
- data/spec/unit_tests/fixtures/files/git_include_exclude.xml +0 -53
- data/spec/unit_tests/fixtures/files/git_include_exclude.yaml +0 -8
- data/spec/unit_tests/fixtures/files/groovy_postbuild.xml +0 -29
- data/spec/unit_tests/fixtures/files/groovy_postbuild.yaml +0 -9
- data/spec/unit_tests/fixtures/files/periodic_build.xml +0 -21
- data/spec/unit_tests/fixtures/files/periodic_build.yaml +0 -5
- data/spec/unit_tests/fixtures/files/post_build_script.xml +0 -28
- data/spec/unit_tests/fixtures/files/post_build_script.yaml +0 -11
- data/spec/unit_tests/fixtures/files/prepare_environment.xml +0 -17
- data/spec/unit_tests/fixtures/files/prepare_environment.yaml +0 -7
- data/spec/unit_tests/fixtures/files/project.yaml +0 -15
- data/spec/unit_tests/fixtures/files/properties_file.xml +0 -27
- data/spec/unit_tests/fixtures/files/properties_file.yaml +0 -8
- data/spec/unit_tests/fixtures/files/remote_job.xml +0 -18
- data/spec/unit_tests/fixtures/files/remote_job.yaml +0 -19
- data/spec/unit_tests/fixtures/files/rvm05.xml +0 -26
- data/spec/unit_tests/fixtures/files/rvm05.yaml +0 -5
- data/spec/unit_tests/fixtures/files/specific_priority.xml +0 -22
- data/spec/unit_tests/fixtures/files/specific_priority.yaml +0 -6
- data/spec/unit_tests/fixtures/files/throttle.xml +0 -17
- data/spec/unit_tests/fixtures/files/throttle.yaml +0 -8
- data/spec/unit_tests/fixtures/files/upstream.xml +0 -17
- data/spec/unit_tests/fixtures/files/upstream.yaml +0 -7
- data/spec/unit_tests/fixtures/pull_request/00.yaml +0 -14
- data/spec/unit_tests/fixtures/pull_request/10.yaml +0 -7
- data/spec/unit_tests/fixtures/pull_request/11.yaml +0 -4
- data/spec/unit_tests/fixtures/pull_request/project.yaml +0 -11
- data/spec/unit_tests/fixtures/templates/external_job.yaml +0 -4
- data/spec/unit_tests/fixtures/templates/project_with_jobs.yaml +0 -25
- data/spec/unit_tests/generator_spec.rb +0 -94
- data/spec/unit_tests/module_registry_spec.rb +0 -16
- data/spec/unit_tests/resolve_dependencies_spec.rb +0 -266
@@ -20,137 +20,206 @@
|
|
20
20
|
# THE SOFTWARE.
|
21
21
|
#
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
23
|
+
job_attribute do
|
24
|
+
name :description
|
25
|
+
plugin_id 123
|
26
|
+
min_version 0
|
27
|
+
announced false
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
XmlHelper.update_node_text(n_xml, '//scm/excludedRegions', params[:excluded_regions]) if params[:excluded_regions]
|
39
|
-
XmlHelper.update_node_text(n_xml, '//scm/includedRegions', params[:included_regions]) if params[:included_regions]
|
40
|
-
end
|
29
|
+
before do
|
30
|
+
xpath('//project/description').remove
|
31
|
+
end
|
32
|
+
|
33
|
+
xml('//project') do |description|
|
34
|
+
description "#{description}"
|
35
|
+
end
|
36
|
+
end
|
41
37
|
|
42
|
-
|
43
|
-
|
38
|
+
job_attribute do
|
39
|
+
name :scm_params
|
40
|
+
plugin_id 123
|
41
|
+
min_version 0
|
42
|
+
announced false
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
# XML preprocessing
|
45
|
+
# TODO: Actually figure out how to merge using the builder DSL
|
46
|
+
# This delete the things we are going to add later is pretty crappy
|
47
|
+
# Alternately don't use/tweak the xml the api client generates
|
48
|
+
# (which is where I assume this is coming from)
|
49
|
+
before do |params|
|
50
|
+
xpath('//scm/localBranch').remove if params[:local_branch]
|
51
|
+
xpath('//scm/recursiveSubmodules').remove if params[:recursive_update]
|
52
|
+
xpath('//scm/wipeOutWorkspace').remove if params[:wipe_workspace]
|
53
|
+
xpath('//scm/excludedUsers').remove if params[:excluded_users]
|
54
|
+
xpath('//scm/userRemoteConfigs').remove if params[:remote_name] || params[:refspec]
|
55
|
+
xpath('//scm/skipTag').remove if params[:skip_tag]
|
56
|
+
xpath('//scm/excludedRegions').remove if params[:excluded_regions]
|
57
|
+
xpath('//scm/includedRegions').remove if params[:included_regions]
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
xml '//scm' do |params|
|
62
|
+
localBranch params[:local_branch] if params[:local_branch]
|
63
|
+
recursiveSubmodules params[:recursive_update] if params[:recursive_update]
|
64
|
+
wipeOutWorkspace params[:wipe_workspace] if params[:wipe_workspace]
|
65
|
+
excludedUsers params[:excluded_users] if params[:excluded_users]
|
66
|
+
if params[:remote_name]
|
67
|
+
userRemoteConfigs do
|
68
|
+
send('hudson.plugins.git.UserRemoteConfig') do
|
69
|
+
name params[:remote_name]
|
50
70
|
end
|
51
71
|
end
|
52
72
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
xml.useJobPriority params[:use_priority]
|
59
|
-
xml.priority params[:job_priority] || -1
|
73
|
+
skipTag params[:skip_tag] if params[:skip_tag]
|
74
|
+
if params[:refspec]
|
75
|
+
userRemoteConfigs do
|
76
|
+
send 'hudson.plugins.git.UserRemoteConfig' do
|
77
|
+
refspec params[:refspec]
|
60
78
|
end
|
61
79
|
end
|
62
80
|
end
|
81
|
+
excludedRegions params[:excluded_regions] if params[:excluded_regions]
|
82
|
+
includedRegions params[:included_regions] if params[:included_regions]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
job_attribute do
|
87
|
+
name :hipchat
|
88
|
+
plugin_id 123
|
89
|
+
min_version 0
|
90
|
+
announced false
|
91
|
+
|
92
|
+
xml '//properties' do |params|
|
93
|
+
fail 'No HipChat room specified' unless params[:room]
|
94
|
+
|
95
|
+
send('jenkins.plugins.hipchat.HipChatNotifier_-HipChatJobProperty') do
|
96
|
+
room params[:room]
|
97
|
+
startNotification params[:'start-notify'] || false
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
job_attribute do
|
103
|
+
name :priority
|
104
|
+
plugin_id 123
|
105
|
+
min_version 0
|
106
|
+
announced false
|
107
|
+
|
108
|
+
xml '//properties' do |params|
|
109
|
+
send('jenkins.advancedqueue.AdvancedQueueSorterJobProperty', 'plugin' => 'PrioritySorter') do
|
110
|
+
useJobPriority params[:use_priority]
|
111
|
+
priority params[:job_priority] || -1
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
job_attribute do
|
117
|
+
name :parameters
|
118
|
+
plugin_id 123
|
119
|
+
min_version 0
|
120
|
+
announced false
|
63
121
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
122
|
+
xml '//properties' do |params|
|
123
|
+
send('hudson.model.ParametersDefinitionProperty') do
|
124
|
+
parameterDefinitions do
|
125
|
+
params.each do |param|
|
126
|
+
case param[:type]
|
127
|
+
when 'string'
|
128
|
+
paramType = 'hudson.model.StringParameterDefinition'
|
129
|
+
when 'bool'
|
130
|
+
paramType = 'hudson.model.BooleanParameterDefinition'
|
131
|
+
when 'text'
|
132
|
+
paramType = 'hudson.model.TextParameterDefinition'
|
133
|
+
when 'password'
|
134
|
+
paramType = 'hudson.model.PasswordParameterDefinition'
|
135
|
+
when 'choice'
|
136
|
+
paramType = 'hudson.model.ChoiceParameterDefinition'
|
137
|
+
else
|
138
|
+
paramType = 'hudson.model.StringParameterDefinition'
|
139
|
+
end
|
140
|
+
|
141
|
+
send(paramType) do
|
142
|
+
name param[:name]
|
143
|
+
description param[:description]
|
144
|
+
defaultValue param[:default]
|
145
|
+
if param[:type] == 'choice'
|
146
|
+
choices('class' => 'java.util.Arrays$ArrayList') do
|
147
|
+
a('class' => 'string-array') do
|
148
|
+
param[:values].each do |value|
|
149
|
+
string value
|
81
150
|
end
|
82
151
|
end
|
83
152
|
end
|
84
153
|
end
|
85
|
-
params.each do |param|
|
86
|
-
case param[:type]
|
87
|
-
when 'string'
|
88
|
-
paramType = 'hudson.model.StringParameterDefinition'
|
89
|
-
when 'bool'
|
90
|
-
paramType = 'hudson.model.BooleanParameterDefinition'
|
91
|
-
when 'text'
|
92
|
-
paramType = 'hudson.model.TextParameterDefinition'
|
93
|
-
when 'password'
|
94
|
-
paramType = 'hudson.model.PasswordParameterDefinition'
|
95
|
-
when 'choice'
|
96
|
-
paramType = 'hudson.model.ChoiceParameterDefinition'
|
97
|
-
else
|
98
|
-
paramType = 'hudson.model.StringParameterDefinition'
|
99
|
-
end
|
100
|
-
|
101
|
-
param_proc.call xml, param, paramType
|
102
|
-
end
|
103
154
|
end
|
104
155
|
end
|
105
156
|
end
|
106
157
|
end
|
158
|
+
end
|
159
|
+
end
|
107
160
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
161
|
+
job_attribute do
|
162
|
+
name :discard_old
|
163
|
+
plugin_id 123
|
164
|
+
min_version 0
|
165
|
+
announced false
|
166
|
+
|
167
|
+
xml '//project' do |params|
|
168
|
+
send('logRotator', 'class' => 'hudson.tasks.LogRotator') do
|
169
|
+
daysToKeep params[:days] if params[:days]
|
170
|
+
numToKeep params[:number] || -1
|
171
|
+
artifactDaysToKeep params[:artifact_days] || -1
|
172
|
+
artifactNumToKeep params[:artifact_number] || -1
|
118
173
|
end
|
174
|
+
end
|
175
|
+
end
|
119
176
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
177
|
+
job_attribute do
|
178
|
+
name :throttle
|
179
|
+
plugin_id 100
|
180
|
+
min_version 0
|
181
|
+
announced false
|
182
|
+
|
183
|
+
xml '//properties' do |params|
|
184
|
+
cat_set = params[:option] == 'category'
|
185
|
+
send('hudson.plugins.throttleconcurrents.ThrottleJobProperty', 'plugin' => 'throttle-concurrents') do
|
186
|
+
maxConcurrentPerNode params[:max_per_node] || 0
|
187
|
+
maxConcurrentTotal params[:max_total] || 0
|
188
|
+
throttleEnabled true
|
189
|
+
throttleOption params[:option] || 'alone'
|
190
|
+
categories do
|
191
|
+
string params[:category] if cat_set
|
133
192
|
end
|
134
193
|
end
|
194
|
+
end
|
195
|
+
end
|
135
196
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
end
|
197
|
+
job_attribute do
|
198
|
+
name :prepare_environment
|
199
|
+
plugin_id 123
|
200
|
+
min_version 0
|
201
|
+
announced false
|
202
|
+
|
203
|
+
xml '//properties' do |params|
|
204
|
+
send('EnvInjectJobProperty') do
|
205
|
+
info do
|
206
|
+
propertiesContent params[:properties_content] if params[:properties_content]
|
207
|
+
loadFilesFromMaster params[:load_from_master] if params[:load_from_master]
|
148
208
|
end
|
209
|
+
on true
|
210
|
+
keepJenkinsSystemVariables params[:keep_environment] if params[:keep_environment]
|
211
|
+
keepBuildVariables params[:keep_build] if params[:keep_build]
|
149
212
|
end
|
213
|
+
end
|
214
|
+
end
|
150
215
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
216
|
+
job_attribute do
|
217
|
+
name :concurrent_build
|
218
|
+
plugin_id 123
|
219
|
+
min_version 0
|
220
|
+
announced false
|
221
|
+
|
222
|
+
xml '//concurrentBuild' do |params|
|
223
|
+
(params == true) ? 'true' : 'false'
|
155
224
|
end
|
156
225
|
end
|
@@ -23,49 +23,32 @@
|
|
23
23
|
module JenkinsPipelineBuilder
|
24
24
|
class ModuleRegistry
|
25
25
|
attr_accessor :registry, :registered_modules
|
26
|
-
ENTRIES = {
|
27
|
-
builders: '//builders',
|
28
|
-
publishers: '//publishers',
|
29
|
-
wrappers: '//buildWrappers',
|
30
|
-
triggers: '//triggers'
|
31
|
-
}
|
32
|
-
|
33
|
-
# creates register_triggers and so on
|
34
|
-
# we declare job attribues below since it doesn't follow the pattern
|
35
|
-
ENTRIES.keys.each do |key|
|
36
|
-
# TODO: Too lazy to figure out a better way to do this
|
37
|
-
singular_key = key.to_s.singularize.to_sym
|
38
|
-
define_method "register_#{singular_key}" do |name, jenkins_name, description, &block|
|
39
|
-
@registered_modules[key][name] = {
|
40
|
-
jenkins_name: jenkins_name,
|
41
|
-
description: description
|
42
|
-
}
|
43
|
-
@registry[:job][key][:registry][name] = block
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
26
|
def initialize
|
48
27
|
@registry = { job: {} }
|
49
|
-
|
28
|
+
end
|
50
29
|
|
51
|
-
|
52
|
-
|
53
|
-
@registry[:job][key] = {}
|
54
|
-
@registry[:job][key][:registry] = {}
|
55
|
-
@registry[:job][key][:method] = ->(registry, params, n_xml) { run_registry_on_path(value, registry, params, n_xml) }
|
56
|
-
end
|
30
|
+
def logger
|
31
|
+
JenkinsPipelineBuilder.logger
|
57
32
|
end
|
58
33
|
|
34
|
+
# Ideally refactor this out to be derived from the registry,
|
35
|
+
# but I'm lazy for now
|
59
36
|
def entries
|
60
|
-
|
37
|
+
{
|
38
|
+
builders: '//builders',
|
39
|
+
publishers: '//publishers',
|
40
|
+
wrappers: '//buildWrappers',
|
41
|
+
triggers: '//triggers'
|
42
|
+
}
|
61
43
|
end
|
62
44
|
|
63
|
-
def
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
45
|
+
def register(prefix, extension)
|
46
|
+
name = prefix.pop
|
47
|
+
root = prefix.inject(@registry, :[])
|
48
|
+
root[name] = {} unless root[name]
|
49
|
+
|
50
|
+
root[name][extension.name] = [] unless root[name][extension.name]
|
51
|
+
root[name][extension.name] << extension
|
69
52
|
end
|
70
53
|
|
71
54
|
def get(path)
|
@@ -85,36 +68,37 @@ module JenkinsPipelineBuilder
|
|
85
68
|
traverse_registry(registry, params, n_xml)
|
86
69
|
end
|
87
70
|
|
88
|
-
def traverse_registry(registry, params, n_xml)
|
71
|
+
def traverse_registry(registry, params, n_xml, strict = false)
|
89
72
|
params.each do |key, value|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
registry_item.call(value, n_xml) unless registry_item.nil?
|
73
|
+
next unless registry.is_a? Hash
|
74
|
+
unless registry.key? key
|
75
|
+
fail "!!!! could not find key #{key} !!!!" if strict
|
76
|
+
next
|
77
|
+
end
|
78
|
+
reg_value = registry[key]
|
79
|
+
if reg_value.is_a?(Array) && reg_value.first.is_a?(Extension)
|
80
|
+
next unless reg_value.select { |x| x.class == Extension }.size == reg_value.size
|
81
|
+
# TODO: Actually compare versions installed on box here
|
82
|
+
reg = reg_value.sort { |x, y| x.min_version <=> y.min_version }.last
|
83
|
+
logger.debug "Using #{reg.type} #{reg.name} version #{reg.min_version}"
|
84
|
+
execute_extension(reg, value, n_xml)
|
85
|
+
elsif value.is_a? Hash
|
86
|
+
traverse_registry reg_value, value, n_xml, true
|
87
|
+
elsif value.is_a? Array
|
88
|
+
value.each do |v|
|
89
|
+
traverse_registry reg_value, v, n_xml, true
|
90
|
+
end
|
91
|
+
end
|
110
92
|
end
|
111
93
|
end
|
112
94
|
|
113
|
-
def
|
114
|
-
n_builders = n_xml.xpath(path).first
|
95
|
+
def execute_extension(extension, value, n_xml)
|
96
|
+
n_builders = n_xml.xpath(extension.path).first
|
97
|
+
n_builders.instance_exec(value, &extension.before) if extension.before
|
115
98
|
Nokogiri::XML::Builder.with(n_builders) do |xml|
|
116
|
-
|
99
|
+
xml.instance_exec value, &extension.xml
|
117
100
|
end
|
101
|
+
n_builders.instance_exec(value, &extension.after) if extension.after
|
118
102
|
end
|
119
103
|
end
|
120
104
|
end
|
@@ -18,135 +18,208 @@
|
|
18
18
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
20
|
# THE SOFTWARE.
|
21
|
-
#
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
22
|
+
publisher do
|
23
|
+
name :description_setter
|
24
|
+
plugin_id 123
|
25
|
+
min_version 0
|
26
|
+
announced false
|
27
|
+
|
28
|
+
xml do |params|
|
29
|
+
send('hudson.plugins.descriptionsetter.DescriptionSetterPublisher') do
|
30
|
+
regexp params[:regexp]
|
31
|
+
regexpForFailed params[:regexp]
|
32
|
+
description params[:description]
|
33
|
+
descriptionForFailed params[:description]
|
34
|
+
setForMatrix false
|
33
35
|
end
|
36
|
+
end
|
37
|
+
end
|
34
38
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
publisher do
|
40
|
+
name :downstream
|
41
|
+
plugin_id 123
|
42
|
+
min_version 0
|
43
|
+
announced false
|
44
|
+
|
45
|
+
xml do |params|
|
46
|
+
send('hudson.plugins.parameterizedtrigger.BuildTrigger') do
|
47
|
+
configs do
|
48
|
+
send('hudson.plugins.parameterizedtrigger.BuildTriggerConfig') do
|
49
|
+
configs do
|
50
|
+
params[:data] = [{ params: '' }] unless params[:data]
|
51
|
+
params[:data].each do |config|
|
52
|
+
if config[:params]
|
53
|
+
send('hudson.plugins.parameterizedtrigger.PredefinedBuildParameters') do
|
54
|
+
properties config[:params]
|
46
55
|
end
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
56
|
+
end
|
57
|
+
if config[:file]
|
58
|
+
send('hudson.plugins.parameterizedtrigger.FileBuildParameters') do
|
59
|
+
propertiesFile config[:file]
|
60
|
+
failTriggerOnMissing false
|
52
61
|
end
|
53
62
|
end
|
54
63
|
end
|
55
|
-
xml.projects params[:project]
|
56
|
-
xml.condition params[:condition] || 'SUCCESS'
|
57
|
-
xml.triggerWithNoParameters params[:trigger_with_no_parameters] || false
|
58
64
|
end
|
65
|
+
projects params[:project]
|
66
|
+
condition params[:condition] || 'SUCCESS'
|
67
|
+
triggerWithNoParameters params[:trigger_with_no_parameters] || false
|
59
68
|
end
|
60
69
|
end
|
61
70
|
end
|
71
|
+
end
|
72
|
+
end
|
62
73
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
74
|
+
publisher do
|
75
|
+
name :hipchat
|
76
|
+
plugin_id 101
|
77
|
+
min_version 0
|
78
|
+
announced false
|
79
|
+
|
80
|
+
xml do |params|
|
81
|
+
params = {} if params == true
|
82
|
+
send('jenkins.plugins.hipchat.HipChatNotifier') do
|
83
|
+
jenkinsUrl params[:jenkinsUrl] || ''
|
84
|
+
authToken params[:authToken] || ''
|
85
|
+
room params[:room] || ''
|
70
86
|
end
|
87
|
+
end
|
88
|
+
end
|
71
89
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
90
|
+
publisher do
|
91
|
+
name :git
|
92
|
+
plugin_id 123
|
93
|
+
min_version 0
|
94
|
+
announced false
|
95
|
+
|
96
|
+
xml do |params|
|
97
|
+
send('hudson.plugins.git.GitPublisher') do
|
98
|
+
configVersion params[:configVersion] || 2
|
99
|
+
pushMerge params[:'push-merge'] || false
|
100
|
+
pushOnlyIfSuccess params[:'push-only-if-success'] || false
|
101
|
+
branchesToPush do
|
102
|
+
send('hudson.plugins.git.GitPublisher_-BranchToPush') do
|
103
|
+
targetRepoName params[:targetRepoName] || 'origin'
|
104
|
+
branchName params[:branchName] || 'master'
|
82
105
|
end
|
83
106
|
end
|
84
107
|
end
|
108
|
+
end
|
109
|
+
end
|
85
110
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
111
|
+
publisher do
|
112
|
+
name :junit_result
|
113
|
+
plugin_id 123
|
114
|
+
min_version 0
|
115
|
+
announced false
|
116
|
+
|
117
|
+
xml do |params|
|
118
|
+
send('hudson.tasks.junit.JUnitResultArchiver') do
|
119
|
+
testResults params[:test_results] || ''
|
120
|
+
keepLongStdio false
|
121
|
+
testDataPublishers
|
92
122
|
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
publisher do
|
127
|
+
name :coverage_result
|
128
|
+
plugin_id 123
|
129
|
+
min_version 0
|
130
|
+
announced false
|
93
131
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
132
|
+
xml do |params|
|
133
|
+
send('hudson.plugins.rubyMetrics.rcov.RcovPublisher') do
|
134
|
+
reportDir params[:report_dir]
|
135
|
+
targets do
|
136
|
+
{ 'TOTAL_COVERAGE' => params[:total], 'CODE_COVERAGE' => params[:code] }.each do |key, inner_params|
|
137
|
+
send('hudson.plugins.rubyMetrics.rcov.model.MetricTarget') do
|
138
|
+
metric key
|
139
|
+
healthy inner_params[:healthy]
|
140
|
+
unhealthy inner_params[:unhealthy]
|
141
|
+
unstable inner_params[:unstable]
|
142
|
+
end
|
100
143
|
end
|
101
144
|
end
|
102
145
|
end
|
146
|
+
end
|
147
|
+
end
|
103
148
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
149
|
+
publisher do
|
150
|
+
name :post_build_script
|
151
|
+
plugin_id 123
|
152
|
+
min_version 0
|
153
|
+
announced false
|
154
|
+
|
155
|
+
xml do |params|
|
156
|
+
send('org.jenkinsci.plugins.postbuildscript.PostBuildScript') do
|
157
|
+
buildSteps do
|
158
|
+
if params[:shell_command]
|
159
|
+
send('hudson.tasks.Shell') do
|
160
|
+
command params[:shell_command]
|
111
161
|
end
|
112
162
|
end
|
113
|
-
xml.scriptOnlyIfSuccess params[:on_success]
|
114
|
-
xml.scriptOnlyIfFailure params[:on_failure]
|
115
|
-
xml.executeOn params[:execute_on] || 'BOTH'
|
116
163
|
end
|
164
|
+
scriptOnlyIfSuccess params[:on_success]
|
165
|
+
scriptOnlyIfFailure params[:on_failure]
|
166
|
+
executeOn params[:execute_on] || 'BOTH'
|
117
167
|
end
|
168
|
+
end
|
169
|
+
end
|
118
170
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
171
|
+
publisher do
|
172
|
+
name :groovy_postbuild
|
173
|
+
plugin_id 123
|
174
|
+
min_version 0
|
175
|
+
announced false
|
176
|
+
|
177
|
+
xml do |params|
|
178
|
+
send('org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder', 'plugin' => 'groovy-postbuild') do
|
179
|
+
groovyScript params[:groovy_script]
|
180
|
+
behavior params[:behavior] || '0'
|
181
|
+
runFormMatrixParent 'false'
|
182
|
+
if params[:additional_classpaths]
|
183
|
+
params[:additional_classpaths].each do |path|
|
184
|
+
send('org.jvnet.hudson.plugins.groovypostbuild.GroovyScriptPath') do
|
185
|
+
path path[:path] || '/'
|
129
186
|
end
|
130
187
|
end
|
131
188
|
end
|
132
189
|
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
publisher do
|
194
|
+
name :archive_artifact
|
195
|
+
plugin_id 123
|
196
|
+
min_version 0
|
197
|
+
announced false
|
198
|
+
|
199
|
+
xml do |params|
|
200
|
+
send('hudson.tasks.ArtifactArchiver') do
|
201
|
+
artifacts params[:artifacts]
|
202
|
+
excludes params[:excludes] if params[:excludes]
|
203
|
+
latestOnly params[:latest_only] || false
|
204
|
+
allowEmptyArchive params[:allow_empty] || false
|
133
205
|
|
134
|
-
register :archive_artifact do |params, xml|
|
135
|
-
xml.send('hudson.tasks.ArtifactArchiver') do
|
136
|
-
xml.artifacts params[:artifacts]
|
137
|
-
xml.excludes params[:excludes] if params[:excludes]
|
138
|
-
xml.latestOnly params[:latest_only] || false
|
139
|
-
xml.allowEmptyArchive params[:allow_empty] || false
|
140
|
-
end
|
141
206
|
end
|
207
|
+
end
|
208
|
+
end
|
142
209
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
210
|
+
publisher do
|
211
|
+
name :email_notifications
|
212
|
+
plugin_id 123
|
213
|
+
min_version 0
|
214
|
+
announced false
|
215
|
+
|
216
|
+
xml do |params|
|
217
|
+
send 'hudson.tasks.Mailer', 'plugin' => 'mailer' do
|
218
|
+
recipients params[:recipients] || ''
|
219
|
+
send_unstable = false
|
220
|
+
send_unstable = true if params[:send_if_unstable] == false
|
221
|
+
dontNotifyEveryUnstableBuild send_unstable
|
222
|
+
sendToIndividuals params[:send_to_individuals] if params[:send_to_individuals]
|
150
223
|
end
|
151
224
|
end
|
152
225
|
end
|