jenkins_pipeline_builder 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +66 -0
- data/lib/jenkins_pipeline_builder/compiler.rb +10 -6
- data/lib/jenkins_pipeline_builder/extensions/wrappers.rb +21 -0
- data/lib/jenkins_pipeline_builder/version.rb +1 -1
- data/lib/jenkins_pipeline_builder/view.rb +1 -1
- data/spec/lib/jenkins_pipeline_builder/compiler_spec.rb +38 -0
- data/spec/lib/jenkins_pipeline_builder/extensions/wrappers_spec.rb +16 -0
- data/spec/lib/jenkins_pipeline_builder/module_registry_spec.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OWM0OWI1ZDRjYjQxYWZmYThlYmIxZmY3ODhkNjA1ZDI3MTRhYzYyZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzUyNWQyM2NlOWJlMTEzZjQzMzM0ZTAwYzkzNzFlNWI2MDA5ZGEzMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWU4ODMxYjA0YTMwNWVkODkyNjk2NDA1MjIwNTMxNjg3Yzg2NDY2NTU3M2Q4
|
10
|
+
ODU2MmQ1ZjJkMmRkMTNjOWQyYWY5YzI1MjY5Y2NhMzg5OWQ4NzEzMTUzZTBh
|
11
|
+
ODcwOGQ3N2E2MzFjNTIxYzQyZThjYmM3YzI3OGU0ZDdhZmJlYjc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjA1MTMwMTE3MjU1ZTZjNzlmZDMwZmY0Mzc1NzY0OTdjYWVlY2VkZGE3ODgz
|
14
|
+
NzcwMTY0ZGFmNDVlNWY5NGEwNjY2ZjZjZmMxMTk0Y2YyMWU3OGY5NTk2NTZi
|
15
|
+
OTdlYjIyMDdjNDA4NWMyYTgzMzhlZmFlOWRmYjAwNWY0ZjYwODg=
|
data/README.md
CHANGED
@@ -289,6 +289,72 @@ Here's a high level overview of what's available:
|
|
289
289
|
NOTE: The *promoted_builds* plugin is not fully implemented. This plugin just helps you point to the jobs that you have in order to promote your build.
|
290
290
|
You need to manually create your promotion rules. Using this plugin will help you regenerate your jobs without breaking your manual promotion jobs.
|
291
291
|
|
292
|
+
### Enable Blocks
|
293
|
+
Blocks can be enabled and disabled like so:
|
294
|
+
|
295
|
+
Project.yaml
|
296
|
+
```yaml
|
297
|
+
- defaults:
|
298
|
+
name: global
|
299
|
+
description: DB Pipeline tooling
|
300
|
+
git_repo: git@github.roving.com:devops/DBPipeline.git
|
301
|
+
git_branch: master
|
302
|
+
excluded_user: buildmaster
|
303
|
+
hipchat_room: CD Builds
|
304
|
+
hipchat_auth_token: f3e98ed54605b36f56dd2c562e3775
|
305
|
+
discard_days: '30'
|
306
|
+
discard_number: '100'
|
307
|
+
maven_name: 'tools-maven-3.0.3'
|
308
|
+
hipchat_jenkins_url: 'https://cd-jenkins.ad.prodcc.net/'
|
309
|
+
|
310
|
+
- project:
|
311
|
+
name: 'PushTest'
|
312
|
+
hipchat_jenkins_url: 'https://cd-jenkins.ad.prodcc.net/'
|
313
|
+
jobs:
|
314
|
+
- '{{name}}-build':
|
315
|
+
use: true
|
316
|
+
```
|
317
|
+
|
318
|
+
build.yaml
|
319
|
+
```yaml
|
320
|
+
- job:
|
321
|
+
name: '{{name}}-build'
|
322
|
+
project_name: '{{name}}'
|
323
|
+
builders:
|
324
|
+
- maven3:
|
325
|
+
enabled: '{{use}}'
|
326
|
+
parameters:
|
327
|
+
rootPom: one
|
328
|
+
```
|
329
|
+
|
330
|
+
If use is true, the params are applied to the maven3 block as seen
|
331
|
+
below:
|
332
|
+
|
333
|
+
build.yaml
|
334
|
+
```yaml
|
335
|
+
- job:
|
336
|
+
name: '{{name}}-build'
|
337
|
+
project_name: '{{name}}'
|
338
|
+
builders:
|
339
|
+
- maven3:
|
340
|
+
rootPom: one
|
341
|
+
```
|
342
|
+
|
343
|
+
The above two build.yaml files are equivalent (for use: true)
|
344
|
+
|
345
|
+
The block needs to have both an enabled and parameters key, and no other
|
346
|
+
keys for the enables to work. Also note that this will fail:
|
347
|
+
|
348
|
+
```yaml
|
349
|
+
enabled: {{use}}
|
350
|
+
```
|
351
|
+
|
352
|
+
While this will work:
|
353
|
+
|
354
|
+
```yaml
|
355
|
+
enabled: '{{use}}'
|
356
|
+
```
|
357
|
+
|
292
358
|
### Pull Request Generator
|
293
359
|
|
294
360
|
The pull request generator will generate pipelines for pull requests that are noticed on your repo. It will also remove old pipelines from Jenkins if the pull_request is closed.
|
@@ -38,7 +38,7 @@ module JenkinsPipelineBuilder
|
|
38
38
|
vars = value_s.scan(/{{([^{}@]+)}}/).flatten
|
39
39
|
vars.select! do |var|
|
40
40
|
var_val = settings[var]
|
41
|
-
value_s.gsub!("{{#{var}}}", var_val) unless var_val.nil?
|
41
|
+
value_s.gsub!("{{#{var}}}", var_val.to_s) unless var_val.nil?
|
42
42
|
var_val.nil?
|
43
43
|
end
|
44
44
|
return nil if vars.count != 0
|
@@ -103,21 +103,25 @@ module JenkinsPipelineBuilder
|
|
103
103
|
[true, result]
|
104
104
|
end
|
105
105
|
|
106
|
-
def self.handle_enable(item)
|
106
|
+
def self.handle_enable(item, settings, job_collection)
|
107
107
|
if item.key?(:enabled) && item.key?(:parameters) && item.length == 2
|
108
|
-
|
108
|
+
enabled_switch = resolve_value(item[:enabled], settings, job_collection)
|
109
|
+
return [true, {}] if enabled_switch == 'false'
|
110
|
+
return [false, { 'value error' => "Invalid value for #{item[:enabled]}: #{enabled_switch}" }] \
|
111
|
+
if enabled_switch != 'true'
|
109
112
|
item = item.merge item[:parameters]
|
110
113
|
item.delete :parameters
|
111
114
|
item.delete :enabled
|
112
115
|
end
|
113
|
-
item
|
116
|
+
[true, item]
|
114
117
|
end
|
115
118
|
|
116
119
|
def self.compile_hash(item, settings, job_collection)
|
117
120
|
errors = {}
|
118
121
|
result = {}
|
119
122
|
|
120
|
-
item = handle_enable
|
123
|
+
success, item = handle_enable(item, settings, job_collection)
|
124
|
+
return false, item unless success
|
121
125
|
|
122
126
|
item.each do |key, value|
|
123
127
|
if value.nil?
|
@@ -133,7 +137,7 @@ module JenkinsPipelineBuilder
|
|
133
137
|
errors[key] = "Failed to resolve:\n===>key: #{key}\n\n===>value: #{value}\n\n===>of: #{item}"
|
134
138
|
next
|
135
139
|
end
|
136
|
-
result[key] = payload
|
140
|
+
result[key] = payload unless payload == {}
|
137
141
|
end
|
138
142
|
return false, errors unless errors.empty?
|
139
143
|
[true, result]
|
@@ -216,3 +216,24 @@ wrapper do
|
|
216
216
|
end
|
217
217
|
end
|
218
218
|
end
|
219
|
+
|
220
|
+
wrapper do
|
221
|
+
name :xvfb
|
222
|
+
plugin_id 'xvfb'
|
223
|
+
description 'Setup Xvfb display for Selenium with Firefox.'
|
224
|
+
jenkins_name 'Xvfb'
|
225
|
+
announced false
|
226
|
+
|
227
|
+
xml do |params|
|
228
|
+
send('org.jenkinsci.plugins.xvfb.XvfbBuildWrapper') do
|
229
|
+
installationName 'Default'
|
230
|
+
screen '1024x768x24'
|
231
|
+
debug false
|
232
|
+
self.timeout params[:timeout] || 10 # rubocop:disable Style/RedundantSelf
|
233
|
+
displayNameOffset 1
|
234
|
+
additionalOptions
|
235
|
+
shutdownWithBuild false
|
236
|
+
autoDisplayName false
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
@@ -170,7 +170,7 @@ module JenkinsPipelineBuilder
|
|
170
170
|
def get_columns(type)
|
171
171
|
column_names = ['Status', 'Weather', 'Last Success', 'Last Failure', 'Last Duration', 'Build Button']
|
172
172
|
if type == 'categorizedView'
|
173
|
-
column_names
|
173
|
+
column_names.insert(2, 'Categorized - Job')
|
174
174
|
else
|
175
175
|
column_names.insert(2, 'Name')
|
176
176
|
end
|
@@ -36,4 +36,42 @@ describe JenkinsPipelineBuilder::Compiler do
|
|
36
36
|
expect(result[1]).to eq(job0_compiled)
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
describe '#enable_blocks' do
|
41
|
+
|
42
|
+
it 'generates correct new jobs with true' do
|
43
|
+
item = { enabled: '{{use1}}', parameters: { rootPom: 'path_to_pomasd' } }
|
44
|
+
settings = { name: 'PushTest', description: 'DB Pipeline tooling', git_repo: 'git@github.roving.com:devops/DBPipeline.git', git_branch: 'master', excluded_user: 'buildmaster', hipchat_room: 'CD Builds', hipchat_auth_token: 'f3e98ed54605b36f56dd2c562e3775', discard_days: '30', discard_number: '100', maven_name: 'tools-maven-3.0.3', hipchat_jenkins_url: 'https://cd-jenkins.ad.prodcc.net/', use1: true }
|
45
|
+
job_collection = { '{{name}}-build' => { name: '{{name}}-build', type: :job, value: { name: '{{name}}-build', project_name: '{{name}}', builders: [{ maven3: { enabled: '{{use1}}', parameters: { rootPom: 'path_to_pomasd' } } }] } }, 'global' => { name: 'global', type: :defaults, value: { name: 'global', description: 'DB Pipeline tooling', git_repo: 'git@github.roving.com:devops/DBPipeline.git', git_branch: 'master', excluded_user: 'buildmaster', hipchat_room: 'CD Builds', hipchat_auth_token: 'f3e98ed54605b36f56dd2c562e3775', discard_days: '30', discard_number: '100', maven_name: 'tools-maven-3.0.3', hipchat_jenkins_url: 'https://cd-jenkins.ad.prodcc.net/', use1: true } }, 'PushTest' => { name: 'PushTest', type: :project, value: { name: 'PushTest', hipchat_jenkins_url: 'https://cd-jenkins.ad.prodcc.net/', jobs: [{ :"{{name}}-build" => {} }] }, settings: { name: 'PushTest', description: 'DB Pipeline tooling', git_repo: 'git@github.roving.com:devops/DBPipeline.git', git_branch: 'master', excluded_user: 'buildmaster', hipchat_room: 'CD Builds', hipchat_auth_token: 'f3e98ed54605b36f56dd2c562e3775', discard_days: '30', discard_number: '100', maven_name: 'tools-maven-3.0.3', hipchat_jenkins_url: 'https://cd-jenkins.ad.prodcc.net/', use1: true } } }
|
46
|
+
success, item = compiler.handle_enable(item, settings, job_collection)
|
47
|
+
expect(success).to be true
|
48
|
+
expect(item).to eq(rootPom: 'path_to_pomasd')
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'generates correct new jobs with false' do
|
52
|
+
item = { enabled: '{{use1}}', parameters: { rootPom: 'path_to_pomasd' } }
|
53
|
+
settings = { name: 'PushTest', description: 'DB Pipeline tooling', git_repo: 'git@github.roving.com:devops/DBPipeline.git', git_branch: 'master', excluded_user: 'buildmaster', hipchat_room: 'CD Builds', hipchat_auth_token: 'f3e98ed54605b36f56dd2c562e3775', discard_days: '30', discard_number: '100', maven_name: 'tools-maven-3.0.3', hipchat_jenkins_url: 'https://cd-jenkins.ad.prodcc.net/', use1: false }
|
54
|
+
job_collection = { '{{name}}-build' => { name: '{{name}}-build', type: :job, value: { name: '{{name}}-build', project_name: '{{name}}', builders: [{ maven3: { enabled: '{{use1}}', parameters: { rootPom: 'path_to_pomasd' } } }] } }, 'global' => { name: 'global', type: :defaults, value: { name: 'global', description: 'DB Pipeline tooling', git_repo: 'git@github.roving.com:devops/DBPipeline.git', git_branch: 'master', excluded_user: 'buildmaster', hipchat_room: 'CD Builds', hipchat_auth_token: 'f3e98ed54605b36f56dd2c562e3775', discard_days: '30', discard_number: '100', maven_name: 'tools-maven-3.0.3', hipchat_jenkins_url: 'https://cd-jenkins.ad.prodcc.net/', use1: true } }, 'PushTest' => { name: 'PushTest', type: :project, value: { name: 'PushTest', hipchat_jenkins_url: 'https://cd-jenkins.ad.prodcc.net/', jobs: [{ :"{{name}}-build" => {} }] }, settings: { name: 'PushTest', description: 'DB Pipeline tooling', git_repo: 'git@github.roving.com:devops/DBPipeline.git', git_branch: 'master', excluded_user: 'buildmaster', hipchat_room: 'CD Builds', hipchat_auth_token: 'f3e98ed54605b36f56dd2c562e3775', discard_days: '30', discard_number: '100', maven_name: 'tools-maven-3.0.3', hipchat_jenkins_url: 'https://cd-jenkins.ad.prodcc.net/', use1: true } } }
|
55
|
+
success, item = compiler.handle_enable(item, settings, job_collection)
|
56
|
+
expect(success).to be true
|
57
|
+
expect(item).to eq({})
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'fails when value not found' do
|
61
|
+
item = { enabled: '{{use_fail}}', parameters: { rootPom: 'path_to_pomasd' } }
|
62
|
+
settings = { name: 'PushTest', description: 'DB Pipeline tooling', git_repo: 'git@github.roving.com:devops/DBPipeline.git', git_branch: 'master', excluded_user: 'buildmaster', hipchat_room: 'CD Builds', hipchat_auth_token: 'f3e98ed54605b36f56dd2c562e3775', discard_days: '30', discard_number: '100', maven_name: 'tools-maven-3.0.3', hipchat_jenkins_url: 'https://cd-jenkins.ad.prodcc.net/', use1: true }
|
63
|
+
job_collection = { '{{name}}-build' => { name: '{{name}}-build', type: :job, value: { name: '{{name}}-build', project_name: '{{name}}', builders: [{ maven3: { enabled: '{{use1}}', parameters: { rootPom: 'path_to_pomasd' } } }] } }, 'global' => { name: 'global', type: :defaults, value: { name: 'global', description: 'DB Pipeline tooling', git_repo: 'git@github.roving.com:devops/DBPipeline.git', git_branch: 'master', excluded_user: 'buildmaster', hipchat_room: 'CD Builds', hipchat_auth_token: 'f3e98ed54605b36f56dd2c562e3775', discard_days: '30', discard_number: '100', maven_name: 'tools-maven-3.0.3', hipchat_jenkins_url: 'https://cd-jenkins.ad.prodcc.net/', use1: true } }, 'PushTest' => { name: 'PushTest', type: :project, value: { name: 'PushTest', hipchat_jenkins_url: 'https://cd-jenkins.ad.prodcc.net/', jobs: [{ :"{{name}}-build" => {} }] }, settings: { name: 'PushTest', description: 'DB Pipeline tooling', git_repo: 'git@github.roving.com:devops/DBPipeline.git', git_branch: 'master', excluded_user: 'buildmaster', hipchat_room: 'CD Builds', hipchat_auth_token: 'f3e98ed54605b36f56dd2c562e3775', discard_days: '30', discard_number: '100', maven_name: 'tools-maven-3.0.3', hipchat_jenkins_url: 'https://cd-jenkins.ad.prodcc.net/', use1: true } } }
|
64
|
+
success, _ = compiler.handle_enable(item, settings, job_collection)
|
65
|
+
expect(success).to be false
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'removes empty builders' do
|
69
|
+
item = { enabled: '{{use}}', parameters: { rootPom: 'one' } }
|
70
|
+
settings = { name: 'PushTest', description: 'DB Pipeline tooling', git_repo: 'git@github.roving.com:devops/DBPipeline.git', git_branch: 'master', excluded_user: 'buildmaster', hipchat_room: 'CD Builds', hipchat_auth_token: 'f3e98ed54605b36f56dd2c562e3775', discard_days: '30', discard_number: '100', maven_name: 'tools-maven-3.0.3', hipchat_jenkins_url: 'https://cd-jenkins.ad.prodcc.net/', use: false }
|
71
|
+
job_collection = { '{{name}}-build' => { name: '{{name}}-build', type: :job, value: { name: '{{name}}-build', project_name: '{{name}}', builders: [{ maven3: { enabled: '{{use}}', parameters: { rootPom: 'one' } } }] }, use: false }, 'global' => { name: 'global', type: :defaults, value: { name: 'global', description: 'DB Pipeline tooling', git_repo: 'git@github.roving.com:devops/DBPipeline.git', git_branch: 'master', excluded_user: 'buildmaster', hipchat_room: 'CD Builds', hipchat_auth_token: 'f3e98ed54605b36f56dd2c562e3775', discard_days: '30', discard_number: '100', maven_name: 'tools-maven-3.0.3', hipchat_jenkins_url: 'https://cd-jenkins.ad.prodcc.net/' } }, 'PushTest' => { name: 'PushTest', type: :project, value: { name: 'PushTest', hipchat_jenkins_url: 'https://cd-jenkins.ad.prodcc.net/', jobs: [{ :"{{name}}-build" => { use: false } }] }, settings: { name: 'PushTest', description: 'DB Pipeline tooling', git_repo: 'git@github.roving.com:devops/DBPipeline.git', git_branch: 'master', excluded_user: 'buildmaster', hipchat_room: 'CD Builds', hipchat_auth_token: 'f3e98ed54605b36f56dd2c562e3775', discard_days: '30', discard_number: '100', maven_name: 'tools-maven-3.0.3', hipchat_jenkins_url: 'https://cd-jenkins.ad.prodcc.net/' } } }
|
72
|
+
success, result = compiler.compile_hash(item, settings, job_collection)
|
73
|
+
expect(success).to be true
|
74
|
+
expect(result).to eq({})
|
75
|
+
end
|
76
|
+
end
|
39
77
|
end
|
@@ -46,6 +46,22 @@ describe 'wrappers' do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
context 'xvfb' do
|
50
|
+
before :each do
|
51
|
+
JenkinsPipelineBuilder.registry.registry[:job][:wrappers][:xvfb].installed_version = '0.0'
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'generates correct xml' do
|
55
|
+
JenkinsPipelineBuilder.registry.traverse_registry_path('job', { wrappers: { xvfb: {} } }, @n_xml)
|
56
|
+
|
57
|
+
node = @n_xml.root.xpath('//buildWrappers/org.jenkinsci.plugins.xvfb.XvfbBuildWrapper')
|
58
|
+
puts node.inspect
|
59
|
+
t = node.css('timeout')
|
60
|
+
puts t.inspect
|
61
|
+
expect(node.first).to_not be_nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
49
65
|
context 'timestamp' do
|
50
66
|
before :each do
|
51
67
|
JenkinsPipelineBuilder.registry.registry[:job][:wrappers][:timestamp].installed_version = '0.0'
|
@@ -110,7 +110,8 @@ describe JenkinsPipelineBuilder::ModuleRegistry do
|
|
110
110
|
inject_env_var: ['0'],
|
111
111
|
artifactory: ['0'],
|
112
112
|
maven3artifactory: ['0'],
|
113
|
-
nodejs: ['0']
|
113
|
+
nodejs: ['0'],
|
114
|
+
xvfb: ['0']
|
114
115
|
}
|
115
116
|
registry = JenkinsPipelineBuilder.registry.registry
|
116
117
|
expect(registry[:job][:wrappers].size).to eq wrappers.size
|
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.
|
4
|
+
version: 0.10.1
|
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:
|
12
|
+
date: 2015-01-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|