jenkins_pipeline_builder 1.6.0 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +22 -3
- data/.rubocop_todo.yml +0 -6
- data/.travis.yml +0 -1
- data/Dockerfile +30 -0
- data/README.md +1 -0
- data/jenkins_pipeline_builder.gemspec +5 -8
- data/lib/jenkins_pipeline_builder.rb +2 -2
- data/lib/jenkins_pipeline_builder/cli/describe.rb +0 -2
- data/lib/jenkins_pipeline_builder/cli/helper.rb +3 -2
- data/lib/jenkins_pipeline_builder/cli/list.rb +2 -1
- data/lib/jenkins_pipeline_builder/cli/pipeline.rb +5 -4
- data/lib/jenkins_pipeline_builder/compiler.rb +15 -2
- data/lib/jenkins_pipeline_builder/extension_set.rb +5 -1
- data/lib/jenkins_pipeline_builder/extensions.rb +6 -2
- data/lib/jenkins_pipeline_builder/extensions/build_steps.rb +1 -1
- data/lib/jenkins_pipeline_builder/extensions/helpers/job_attributes/parameters_helper.rb +2 -2
- data/lib/jenkins_pipeline_builder/extensions/helpers/publishers/cobertura_report_helper.rb +1 -0
- data/lib/jenkins_pipeline_builder/extensions/job_attributes.rb +24 -0
- data/lib/jenkins_pipeline_builder/extensions/publishers.rb +26 -1
- data/lib/jenkins_pipeline_builder/extensions/wrappers.rb +2 -1
- data/lib/jenkins_pipeline_builder/generator.rb +7 -2
- data/lib/jenkins_pipeline_builder/job.rb +3 -0
- data/lib/jenkins_pipeline_builder/job_collection.rb +5 -3
- data/lib/jenkins_pipeline_builder/module_registry.rb +4 -0
- data/lib/jenkins_pipeline_builder/promotion.rb +1 -0
- data/lib/jenkins_pipeline_builder/pull_request_generator.rb +12 -11
- data/lib/jenkins_pipeline_builder/remote_dependencies.rb +2 -2
- data/lib/jenkins_pipeline_builder/utils.rb +12 -7
- data/lib/jenkins_pipeline_builder/version.rb +1 -1
- data/lib/jenkins_pipeline_builder/view.rb +3 -1
- data/spec/lib/jenkins_pipeline_builder/cli/helper_spec.rb +1 -1
- data/spec/lib/jenkins_pipeline_builder/compiler_spec.rb +1 -1
- data/spec/lib/jenkins_pipeline_builder/extension_dsl_spec.rb +1 -1
- data/spec/lib/jenkins_pipeline_builder/extension_set_spec.rb +3 -3
- data/spec/lib/jenkins_pipeline_builder/extensions/build_steps_spec.rb +1 -1
- data/spec/lib/jenkins_pipeline_builder/extensions/builders_spec.rb +6 -6
- data/spec/lib/jenkins_pipeline_builder/extensions/job_attributes_spec.rb +1 -1
- data/spec/lib/jenkins_pipeline_builder/extensions/promotion_conditions_spec.rb +1 -1
- data/spec/lib/jenkins_pipeline_builder/extensions/publishers_spec.rb +28 -11
- data/spec/lib/jenkins_pipeline_builder/extensions/registered_spec.rb +3 -1
- data/spec/lib/jenkins_pipeline_builder/extensions/triggers_spec.rb +1 -1
- data/spec/lib/jenkins_pipeline_builder/extensions/wrappers_spec.rb +1 -1
- data/spec/lib/jenkins_pipeline_builder/extensions_spec.rb +1 -1
- data/spec/lib/jenkins_pipeline_builder/fixtures/generator_tests/pullrequest_pipeline/project.yaml +1 -0
- data/spec/lib/jenkins_pipeline_builder/generator_spec.rb +90 -36
- data/spec/lib/jenkins_pipeline_builder/job_collection_spec.rb +2 -2
- data/spec/lib/jenkins_pipeline_builder/job_spec.rb +1 -1
- data/spec/lib/jenkins_pipeline_builder/module_registry_spec.rb +1 -1
- data/spec/lib/jenkins_pipeline_builder/promotion_spec.rb +1 -1
- data/spec/lib/jenkins_pipeline_builder/pull_request_generator_spec.rb +16 -16
- data/spec/lib/jenkins_pipeline_builder/spec_helper.rb +1 -1
- data/spec/lib/jenkins_pipeline_builder/utils_spec.rb +1 -1
- data/spec/lib/jenkins_pipeline_builder/view_spec.rb +2 -2
- data/spec/requests/pipeline_spec.rb +1 -1
- metadata +20 -20
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path('
|
1
|
+
require File.expand_path('../spec_helper', __dir__)
|
2
2
|
|
3
3
|
describe 'publishers' do
|
4
4
|
after :each do
|
@@ -48,16 +48,6 @@ describe 'publishers' do
|
|
48
48
|
expect(additional_properties_value.first.content).to match ''
|
49
49
|
end
|
50
50
|
|
51
|
-
it 'populates branch' do
|
52
|
-
params = { publishers: { sonar_result: { branch: 'test' } } }
|
53
|
-
|
54
|
-
JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
|
55
|
-
|
56
|
-
sonar_nodes = @n_xml.root.children.first.children
|
57
|
-
branch = sonar_nodes.select { |node| node.name == 'branch' }
|
58
|
-
expect(branch.first.content).to match 'test'
|
59
|
-
end
|
60
|
-
|
61
51
|
it 'populates maven installation name' do
|
62
52
|
params = { publishers: { sonar_result: { maven_installation_name: 'test' } } }
|
63
53
|
|
@@ -427,6 +417,33 @@ describe 'publishers' do
|
|
427
417
|
end
|
428
418
|
end
|
429
419
|
|
420
|
+
context 'google_chat' do
|
421
|
+
before :each do
|
422
|
+
allow(JenkinsPipelineBuilder.client).to receive(:plugin).and_return double(
|
423
|
+
list_installed: { 'google-chat-notification' => '0' }
|
424
|
+
)
|
425
|
+
end
|
426
|
+
it 'generates a configuration' do
|
427
|
+
params = { publishers: { google_chat: {} } }
|
428
|
+
|
429
|
+
JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
|
430
|
+
|
431
|
+
publisher = @n_xml.root.children.first
|
432
|
+
expect(publisher.name).to match 'io.cnaik.GoogleChatNotification'
|
433
|
+
children = publisher.children.map(&:name)
|
434
|
+
expect(children).to include 'url'
|
435
|
+
expect(children).to include 'message'
|
436
|
+
expect(children).to include 'notifyAborted'
|
437
|
+
expect(children).to include 'notifyFailure'
|
438
|
+
expect(children).to include 'notifyNotBuilt'
|
439
|
+
expect(children).to include 'notifySuccess'
|
440
|
+
expect(children).to include 'notifyUnstable'
|
441
|
+
expect(children).to include 'notifyBackToNormal'
|
442
|
+
expect(children).to include 'suppressInfoLoggers'
|
443
|
+
expect(children).to include 'sameThreadNotification'
|
444
|
+
end
|
445
|
+
end
|
446
|
+
|
430
447
|
context 'coverage_result' do
|
431
448
|
it 'generates a configuration'
|
432
449
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path('
|
1
|
+
require File.expand_path('../spec_helper', __dir__)
|
2
2
|
WRAPPERS = {
|
3
3
|
ansicolor: ['0'],
|
4
4
|
artifactory: ['0'],
|
@@ -27,6 +27,7 @@ PUBLISHERS = {
|
|
27
27
|
git: ['0'],
|
28
28
|
github_pr_coverage_status_reporter: ['0'],
|
29
29
|
groovy_postbuild: ['0'],
|
30
|
+
google_chat: ['0'],
|
30
31
|
hipchat: ['0', '0.1.9', '2.0.0'],
|
31
32
|
html_publisher: ['0'],
|
32
33
|
junit_result: ['0'],
|
@@ -69,6 +70,7 @@ JOB_ATTRIBUTES = {
|
|
69
70
|
hipchat: ['0', '2.0.0'],
|
70
71
|
inject_env_vars_pre_scm: ['0'],
|
71
72
|
parameters: ['0'],
|
73
|
+
google_chat: ['0'],
|
72
74
|
shared_workspace: ['0'],
|
73
75
|
prepare_environment: ['0'],
|
74
76
|
priority: ['0'],
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path('
|
1
|
+
require File.expand_path('spec_helper', __dir__)
|
2
2
|
|
3
3
|
describe JenkinsPipelineBuilder::Generator do
|
4
4
|
before :all do
|
@@ -89,31 +89,52 @@ describe JenkinsPipelineBuilder::Generator do
|
|
89
89
|
expect(errors).to be_empty
|
90
90
|
end
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
92
|
+
context 'when creating pipeline templates' do
|
93
|
+
before(:each) do
|
94
|
+
tar_path = File.join(__dir__, 'fixtures/generator_tests/template_pipeline/jobs.tar.gz')
|
95
|
+
parsed_url = URI.parse('https://www.test.com')
|
96
|
+
file_contents = Zlib::GzipReader.new(File.open(tar_path)).read
|
97
|
+
file_object = double
|
98
|
+
allow(URI).to receive(:parse).and_return(parsed_url)
|
99
|
+
allow(parsed_url).to receive(:open).and_yield('A String')
|
100
|
+
allow(Zlib::GzipReader).to receive(:new).and_return(file_object)
|
101
|
+
allow(file_object).to receive(:read).and_return(file_contents)
|
102
|
+
end
|
96
103
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
104
|
+
it 'produces no errors while creating pipeline TemplatePipeline' do
|
105
|
+
errors = bootstrap(fixture_path('template_pipeline'), 'TemplatePipeline')
|
106
|
+
expect(errors).to be_empty
|
107
|
+
end
|
101
108
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
end
|
109
|
+
it 'overrides the remote dependencies with local ones' do
|
110
|
+
errors = bootstrap(fixture_path('local_override/remote_and_local'), 'TemplatePipeline')
|
111
|
+
expect(errors).to be_empty
|
112
|
+
expect(@generator.job_collection.collection['{{name}}-10'][:value][:description]).to eq('Overridden stuff')
|
113
|
+
end
|
108
114
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
115
|
+
it 'loads extensions in remote dependencies' do
|
116
|
+
errors = bootstrap(fixture_path('template_pipeline'), 'TemplatePipeline')
|
117
|
+
expect(errors).to be_empty
|
118
|
+
expect(@generator.module_registry.registry[:job][:wrappers].keys).to include :test_wrapper
|
119
|
+
@generator.module_registry.registry[:job][:wrappers].delete(:test_wrapper)
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'fails to override when there are duplicate local items' do
|
123
|
+
expect { bootstrap(fixture_path('local_override/all_local'), 'TemplatePipeline') }.to raise_error(StandardError)
|
124
|
+
end
|
114
125
|
|
115
|
-
|
116
|
-
|
126
|
+
it 'produces no errors while creating pipeline TemplatePipeline_nested' do
|
127
|
+
tar_path = File.join(__dir__, 'fixtures/generator_tests/template_pipeline_nested/jobs.tar.gz')
|
128
|
+
parsed_url = URI.parse('https://www.test.com')
|
129
|
+
file_contents = Zlib::GzipReader.new(File.open(tar_path)).read
|
130
|
+
file_object = double
|
131
|
+
allow(URI).to receive(:parse).and_return(parsed_url)
|
132
|
+
allow(parsed_url).to receive(:open).and_yield('A String')
|
133
|
+
allow(Zlib::GzipReader).to receive(:new).and_return(file_object)
|
134
|
+
allow(file_object).to receive(:read).and_return(file_contents)
|
135
|
+
errors = bootstrap(fixture_path('template_pipeline_nested'), 'TemplatePipeline_nested')
|
136
|
+
expect(errors).to be_empty
|
137
|
+
end
|
117
138
|
end
|
118
139
|
|
119
140
|
# Things to check for:
|
@@ -133,7 +154,10 @@ describe JenkinsPipelineBuilder::Generator do
|
|
133
154
|
JenkinsPipelineBuilder.registry.registry[:job][:scm_params].clear_installed_version
|
134
155
|
end
|
135
156
|
|
136
|
-
let(:
|
157
|
+
let(:pr_master) { { number: 1, base: 'master' } }
|
158
|
+
let(:pr_not_master) { { number: 2, base: 'not-master' } }
|
159
|
+
let(:open_prs) { [pr_master, pr_not_master] }
|
160
|
+
let(:path) { File.expand_path('fixtures/generator_tests/pullrequest_pipeline', __dir__) }
|
137
161
|
it 'produces no errors while creating pipeline PullRequest' do
|
138
162
|
job_name = 'PullRequest'
|
139
163
|
pr_generator = double('pr_generator')
|
@@ -145,7 +169,7 @@ describe JenkinsPipelineBuilder::Generator do
|
|
145
169
|
.and_return(pr_generator)
|
146
170
|
expect(pr_generator).to receive(:delete_closed_prs)
|
147
171
|
expect(pr_generator).to receive(:convert!)
|
148
|
-
expect(pr_generator).to receive(:open_prs).and_return [
|
172
|
+
expect(pr_generator).to receive(:open_prs).and_return [pr_master]
|
149
173
|
success = @generator.pull_request(path, job_name)
|
150
174
|
expect(success).to be_truthy
|
151
175
|
end
|
@@ -161,7 +185,7 @@ describe JenkinsPipelineBuilder::Generator do
|
|
161
185
|
.and_return(pr_generator)
|
162
186
|
expect(pr_generator).to receive(:delete_closed_prs)
|
163
187
|
expect(pr_generator).to receive(:convert!).twice
|
164
|
-
expect(pr_generator).to receive(:open_prs).and_return
|
188
|
+
expect(pr_generator).to receive(:open_prs).and_return open_prs
|
165
189
|
expect(@generator.pull_request(path, job_name)).to be_truthy
|
166
190
|
end
|
167
191
|
|
@@ -175,13 +199,33 @@ describe JenkinsPipelineBuilder::Generator do
|
|
175
199
|
git_repo_name: 'generator_tests'))
|
176
200
|
.and_return(pr_generator)
|
177
201
|
expect(pr_generator).to receive(:delete_closed_prs)
|
178
|
-
allow(pr_generator).to receive(:convert!) do |job_collection,
|
179
|
-
job_collection.defaults[:value][:application_name] = "testapp-PR#{
|
202
|
+
allow(pr_generator).to receive(:convert!) do |job_collection, pr_number|
|
203
|
+
job_collection.defaults[:value][:application_name] = "testapp-PR#{pr_number}"
|
180
204
|
end
|
181
|
-
expect(pr_generator).to receive(:open_prs).and_return
|
205
|
+
expect(pr_generator).to receive(:open_prs).and_return open_prs
|
182
206
|
expect(@generator.pull_request(path, job_name)).to be_truthy
|
183
207
|
expect(@generator.job_collection.projects.first[:settings][:application_name]).to eq 'testapp-PR2'
|
184
208
|
end
|
209
|
+
|
210
|
+
it 'correctly creates jobs only for the base branch' do
|
211
|
+
job_name = 'PullRequest'
|
212
|
+
pr_generator = double('pr_generator')
|
213
|
+
expect(JenkinsPipelineBuilder::PullRequestGenerator).to receive(:new)
|
214
|
+
.with(hash_including(
|
215
|
+
application_name: 'testapp',
|
216
|
+
github_site: 'https://github.com',
|
217
|
+
git_org: 'testorg',
|
218
|
+
git_repo_name: 'generator_tests'
|
219
|
+
)).and_return(pr_generator)
|
220
|
+
|
221
|
+
expect(pr_generator).to receive(:open_prs).and_return open_prs
|
222
|
+
expect(pr_generator).to receive(:delete_closed_prs)
|
223
|
+
expect(pr_generator).to receive(:convert!)
|
224
|
+
.with(instance_of(JenkinsPipelineBuilder::JobCollection), pr_master[:number])
|
225
|
+
.once
|
226
|
+
|
227
|
+
expect(@generator.pull_request(path, job_name, true)).to be_truthy
|
228
|
+
end
|
185
229
|
# Things to check for
|
186
230
|
# Fail - no PR job type found
|
187
231
|
# Encounters failure during build process
|
@@ -204,26 +248,26 @@ describe JenkinsPipelineBuilder::Generator do
|
|
204
248
|
end
|
205
249
|
|
206
250
|
it 'loads a yaml collection from a path' do
|
207
|
-
path = File.expand_path('
|
251
|
+
path = File.expand_path('fixtures/generator_tests/test_yaml_files', __dir__)
|
208
252
|
@generator.job_collection.load_from_path path
|
209
253
|
end
|
210
254
|
it 'loads a json collection from a path' do
|
211
|
-
path = File.expand_path('
|
255
|
+
path = File.expand_path('fixtures/generator_tests/test_json_files', __dir__)
|
212
256
|
@generator.job_collection.load_from_path path
|
213
257
|
end
|
214
258
|
it 'loads both yaml and json files from a path' do
|
215
|
-
path = File.expand_path('
|
259
|
+
path = File.expand_path('fixtures/generator_tests/test_combo_files', __dir__)
|
216
260
|
@generator.job_collection.load_from_path path
|
217
261
|
end
|
218
262
|
|
219
263
|
it 'errors when reading a bad yaml file' do
|
220
|
-
path = File.expand_path('
|
264
|
+
path = File.expand_path('fixtures/generator_tests/test_bad_yaml_files', __dir__)
|
221
265
|
expect { @generator.job_collection.load_from_path path }.to raise_error(
|
222
266
|
CustomErrors::ParseError, /There was an error while parsing a file/
|
223
267
|
)
|
224
268
|
end
|
225
269
|
it 'errors when reading a bad json file' do
|
226
|
-
path = File.expand_path('
|
270
|
+
path = File.expand_path('fixtures/generator_tests/test_bad_json_files', __dir__)
|
227
271
|
expect { @generator.job_collection.load_from_path path }.to raise_error(
|
228
272
|
CustomErrors::ParseError, /There was an error while parsing a file/
|
229
273
|
)
|
@@ -235,7 +279,7 @@ describe JenkinsPipelineBuilder::Generator do
|
|
235
279
|
allow(JenkinsPipelineBuilder).to receive(:debug).and_return true
|
236
280
|
job_name = 'test_job'
|
237
281
|
body = ''
|
238
|
-
test_path = File.expand_path('
|
282
|
+
test_path = File.expand_path('fixtures/generator_tests', __dir__)
|
239
283
|
File.open("#{test_path}/#{job_name}.xml", 'r') do |f|
|
240
284
|
f.each_line do |line|
|
241
285
|
body << line
|
@@ -251,7 +295,7 @@ describe JenkinsPipelineBuilder::Generator do
|
|
251
295
|
|
252
296
|
describe '#projects' do
|
253
297
|
it 'returns a list of projects' do
|
254
|
-
path = File.expand_path('
|
298
|
+
path = File.expand_path('fixtures/generator_tests/multi_project', __dir__)
|
255
299
|
expect(@generator.projects(path)).to eq %w[SamplePipeline1 SamplePipeline2 SamplePipeline3]
|
256
300
|
end
|
257
301
|
end
|
@@ -269,9 +313,19 @@ describe JenkinsPipelineBuilder::Generator do
|
|
269
313
|
File.delete(file_path) if File.exist?(file_path)
|
270
314
|
end
|
271
315
|
end
|
316
|
+
|
272
317
|
it 'generates xml and saves to disk without sending jobs to the server' do
|
318
|
+
tar_path = File.join(__dir__, 'fixtures/generator_tests/template_pipeline_nested/jobs.tar.gz')
|
319
|
+
parsed_url = URI.parse('https://www.test.com')
|
320
|
+
file_contents = Zlib::GzipReader.new(File.open(tar_path)).read
|
321
|
+
file_object = double
|
322
|
+
allow(URI).to receive(:parse).and_return(parsed_url)
|
323
|
+
allow(parsed_url).to receive(:open).and_yield('A String')
|
324
|
+
allow(Zlib::GzipReader).to receive(:new).and_return(file_object)
|
325
|
+
allow(file_object).to receive(:read).and_return(file_contents)
|
326
|
+
|
273
327
|
job_name = 'TemplatePipeline'
|
274
|
-
path = File.expand_path('
|
328
|
+
path = File.expand_path('fixtures/generator_tests/template_pipeline', __dir__)
|
275
329
|
errors = @generator.file(path, job_name)
|
276
330
|
expect(errors).to be_empty
|
277
331
|
expect(File.exist?("out/xml/#{job_name}-10.xml")).to be true
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path('
|
1
|
+
require File.expand_path('spec_helper', __dir__)
|
2
2
|
|
3
3
|
describe JenkinsPipelineBuilder::JobCollection do
|
4
4
|
before :all do
|
@@ -21,7 +21,7 @@ describe JenkinsPipelineBuilder::JobCollection do
|
|
21
21
|
|
22
22
|
context '#load_from_path' do
|
23
23
|
before :all do
|
24
|
-
path = File.expand_path('
|
24
|
+
path = File.expand_path('fixtures/job_collection', __dir__)
|
25
25
|
described_class.new.load_from_path path
|
26
26
|
end
|
27
27
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path('
|
1
|
+
require File.expand_path('spec_helper', __dir__)
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
describe JenkinsPipelineBuilder::PullRequestGenerator do
|
@@ -8,7 +8,7 @@ describe JenkinsPipelineBuilder::PullRequestGenerator do
|
|
8
8
|
let(:git_repo_name) { 'git_repo' }
|
9
9
|
let(:prs) { (1..10).map { |n| "#{application_name}-PR#{n}" } }
|
10
10
|
let(:closed_prs) { (1..6).map { |n| "#{application_name}-PR#{n}" } }
|
11
|
-
let(:open_prs_json) { (7..10).map { |n| { number: n } }.to_json }
|
11
|
+
let(:open_prs_json) { (7..10).map { |n| { number: n, base: { ref: 'master' } } }.to_json }
|
12
12
|
let(:url) { "#{github_site}/api/v3/repos/#{git_org}/#{git_repo_name}/pulls" }
|
13
13
|
let(:params) do
|
14
14
|
{
|
@@ -91,41 +91,41 @@ describe JenkinsPipelineBuilder::PullRequestGenerator do
|
|
91
91
|
.to_return(status: 200, body: open_prs_json, headers: {})
|
92
92
|
end
|
93
93
|
|
94
|
+
let(:pr_number) { 8 }
|
95
|
+
|
94
96
|
it 'converts the job application name' do
|
95
97
|
collection = job_collection.clone
|
96
|
-
subject.convert! collection,
|
97
|
-
expect(collection.defaults[:value][:application_name]).to eq "#{application_name}-
|
98
|
+
subject.convert! collection, pr_number
|
99
|
+
expect(collection.defaults[:value][:application_name]).to eq "#{application_name}-PR#{pr_number}"
|
98
100
|
end
|
99
101
|
|
100
102
|
it 'provides the PR number to the job settings' do
|
101
103
|
collection = job_collection.clone
|
102
|
-
subject.convert! collection,
|
103
|
-
expect(collection.defaults[:value][:pull_request_number]).to eq
|
104
|
+
subject.convert! collection, pr_number
|
105
|
+
expect(collection.defaults[:value][:pull_request_number]).to eq pr_number.to_s
|
104
106
|
end
|
105
107
|
|
106
108
|
it 'overrides the git params' do
|
107
|
-
pr = 8
|
108
109
|
collection = job_collection.clone
|
109
|
-
subject.convert! collection,
|
110
|
+
subject.convert! collection, pr_number
|
110
111
|
expect(collection.jobs.first[:value]).to eq(
|
111
|
-
scm_branch: "origin/pr/#{
|
112
|
+
scm_branch: "origin/pr/#{pr_number}/head",
|
112
113
|
scm_params: {
|
113
|
-
refspec: "refs/pull/#{
|
114
|
-
changelog_to_branch: { remote: 'origin', branch: "pr/#{
|
114
|
+
refspec: "refs/pull/#{pr_number}/head:refs/remotes/origin/pr/#{pr_number}/head",
|
115
|
+
changelog_to_branch: { remote: 'origin', branch: "pr/#{pr_number}/head" },
|
115
116
|
random: 'foo'
|
116
117
|
}
|
117
118
|
)
|
118
119
|
end
|
119
120
|
|
120
121
|
it 'does not override extra params' do
|
121
|
-
pr = 8
|
122
122
|
collection = job_collection.clone
|
123
|
-
subject.convert! collection,
|
123
|
+
subject.convert! collection, pr_number
|
124
124
|
expect(collection.jobs.first[:value]).to eq(
|
125
|
-
scm_branch: "origin/pr/#{
|
125
|
+
scm_branch: "origin/pr/#{pr_number}/head",
|
126
126
|
scm_params: {
|
127
|
-
refspec: "refs/pull/#{
|
128
|
-
changelog_to_branch: { remote: 'origin', branch: "pr/#{
|
127
|
+
refspec: "refs/pull/#{pr_number}/head:refs/remotes/origin/pr/#{pr_number}/head",
|
128
|
+
changelog_to_branch: { remote: 'origin', branch: "pr/#{pr_number}/head" },
|
129
129
|
random: 'foo'
|
130
130
|
}
|
131
131
|
)
|
@@ -6,7 +6,7 @@ require 'simplecov-rcov'
|
|
6
6
|
require 'webmock/rspec'
|
7
7
|
require 'equivalent-xml'
|
8
8
|
|
9
|
-
require File.expand_path('
|
9
|
+
require File.expand_path('../../../lib/jenkins_pipeline_builder', __dir__)
|
10
10
|
|
11
11
|
RSpec::Matchers.define :have_min_version do |version|
|
12
12
|
match do |base|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path('
|
1
|
+
require File.expand_path('spec_helper', __dir__)
|
2
2
|
|
3
3
|
describe JenkinsPipelineBuilder::View do
|
4
4
|
before(:all) do
|
@@ -12,7 +12,7 @@ describe JenkinsPipelineBuilder::View do
|
|
12
12
|
generator = JenkinsPipelineBuilder.generator
|
13
13
|
@view = JenkinsPipelineBuilder::View.new(generator)
|
14
14
|
end
|
15
|
-
let(:path) { File.expand_path('
|
15
|
+
let(:path) { File.expand_path('fixtures/view_test', __dir__) }
|
16
16
|
let(:view) { { name: 'view', parent_view: 'ParentView', type: 'categorizedView', description: 'ViewTest', regex: 'ViewTest.*', groupingRules: [{ groupRegex: 'ViewTest-1.*', namingRule: '1. Commit Stage' }] } }
|
17
17
|
|
18
18
|
describe '#generate' do
|