jenkins_pipeline_builder 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ackrc +4 -0
- data/.gitignore +3 -0
- data/.rspec +1 -0
- data/README.md +16 -5
- data/Rakefile +2 -0
- data/lib/jenkins_pipeline_builder/builders.rb +23 -20
- data/lib/jenkins_pipeline_builder/compiler.rb +1 -1
- data/lib/jenkins_pipeline_builder/generator.rb +12 -2
- data/lib/jenkins_pipeline_builder/version.rb +1 -1
- data/spec/func_tests/view_spec.rb +24 -24
- data/spec/unit_tests/compiler_spec.rb +1 -1
- data/spec/unit_tests/fixtures/files/Job-Multi-Project.xml +20 -4
- data/spec/unit_tests/fixtures/files/Job-Multi-Project.yaml +15 -4
- data/spec/unit_tests/generator_spec.rb +2 -3
- data/spec/unit_tests/spec_helper.rb +2 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c085dfdc7cec7f2d1df4f4d46ec4d2a53854b0d1
|
4
|
+
data.tar.gz: 11741c96a3ffb283b2c88e6d9e2f90452eac2964
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 964a0077ffefc1a869fb1b1ba1f153e244c5752317270521294e3e058e20fb19866021c191f3c3f737357ce5f104ba0ecaaaed2ea9051fc58e9909e78a147456
|
7
|
+
data.tar.gz: 42f1dd78be906eef930b94e63ede816ddae53b859334e2726ad88a5fc1182001e2c8e56a96d0ea10571a5c13f4d620477891c3c255708601bc1e89962e522d22
|
data/.ackrc
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color --tty --format documentation
|
data/README.md
CHANGED
@@ -104,17 +104,28 @@ Here's a high level overview of what's available:
|
|
104
104
|
room: room name here
|
105
105
|
start-notify: true
|
106
106
|
builders:
|
107
|
-
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
107
|
+
- multi_job:
|
108
|
+
phases:
|
109
|
+
"Phase One":
|
110
|
+
jobs:
|
111
|
+
- name: first
|
112
|
+
exposed_scm: true
|
113
|
+
current_params: true
|
114
|
+
config:
|
115
|
+
predefined_build_parameters:
|
116
|
+
- "PARENT_WORKSPACE=${WORKSPACE}"
|
117
|
+
- name: second
|
118
|
+
continue_condition: COMPLETED
|
119
|
+
"Phase Two":
|
120
|
+
jobs:
|
121
|
+
- name: third
|
112
122
|
- inject_vars_file: build_job_info
|
113
123
|
- shell_command: |
|
114
124
|
echo 'Doing some work'
|
115
125
|
run command1
|
116
126
|
- maven3:
|
117
127
|
goals: -B clean
|
128
|
+
rootPom: path_to_pom
|
118
129
|
mavenName: maven-name # Optional
|
119
130
|
wrappers:
|
120
131
|
- timestamp: true
|
data/Rakefile
CHANGED
@@ -22,28 +22,31 @@
|
|
22
22
|
|
23
23
|
module JenkinsPipelineBuilder
|
24
24
|
class Builders
|
25
|
-
def self.
|
26
|
-
|
27
|
-
xml.
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
xml.
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
xml.
|
37
|
-
|
25
|
+
def self.build_multijob(params, xml)
|
26
|
+
params[:phases].each do |name, content|
|
27
|
+
xml.send('com.tikal.jenkins.plugins.multijob.MultiJobBuilder') {
|
28
|
+
xml.phaseName name
|
29
|
+
xml.phaseJobs {
|
30
|
+
content[:jobs].each do |job|
|
31
|
+
xml.send('com.tikal.jenkins.plugins.multijob.PhaseJobsConfig') {
|
32
|
+
xml.jobName job[:name]
|
33
|
+
xml.currParams job[:current_params] || false
|
34
|
+
xml.exposedSCM job[:exposed_scm] || false
|
35
|
+
if job[:config]
|
36
|
+
xml.configs {
|
37
|
+
if job[:config].has_key? :predefined_build_parameters
|
38
|
+
xml.send('hudson.plugins.parameterizedtrigger.PredefinedBuildParameters') {
|
39
|
+
xml.properties job[:config][:predefined_build_parameters].join ' '
|
40
|
+
}
|
41
|
+
end
|
42
|
+
}
|
43
|
+
end
|
38
44
|
}
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
proc.call xml, name
|
43
|
-
end
|
45
|
+
end
|
46
|
+
}
|
47
|
+
xml.continuationCondition content[:continue_condition] || 'SUCCESSFUL'
|
44
48
|
}
|
45
|
-
|
46
|
-
}
|
49
|
+
end
|
47
50
|
end
|
48
51
|
|
49
52
|
def self.build_maven3(params, xml)
|
@@ -38,6 +38,7 @@ module JenkinsPipelineBuilder
|
|
38
38
|
def initialize(args, client)
|
39
39
|
@client = client
|
40
40
|
@logger = @client.logger
|
41
|
+
#@logger.level = (@debug) ? Logger::DEBUG : Logger::INFO;
|
41
42
|
@job_templates = {}
|
42
43
|
@job_collection = {}
|
43
44
|
|
@@ -49,7 +50,7 @@ module JenkinsPipelineBuilder
|
|
49
50
|
parameters: JobBuilder.method(:build_parameters),
|
50
51
|
builders: {
|
51
52
|
registry: {
|
52
|
-
|
53
|
+
multi_job: Builders.method(:build_multijob),
|
53
54
|
inject_vars_file: Builders.method(:build_environment_vars_injector),
|
54
55
|
shell_command: Builders.method(:build_shell_command),
|
55
56
|
maven3: Builders.method(:build_maven3)
|
@@ -95,7 +96,14 @@ module JenkinsPipelineBuilder
|
|
95
96
|
end
|
96
97
|
|
97
98
|
attr_accessor :client
|
98
|
-
attr_accessor :debug
|
99
|
+
#attr_accessor :debug
|
100
|
+
def debug=(value)
|
101
|
+
@debug = value
|
102
|
+
@logger.level = (value) ? Logger::DEBUG : Logger::INFO;
|
103
|
+
end
|
104
|
+
def debug
|
105
|
+
@debug
|
106
|
+
end
|
99
107
|
# TODO: WTF?
|
100
108
|
attr_accessor :no_files
|
101
109
|
attr_accessor :job_collection
|
@@ -109,6 +117,7 @@ module JenkinsPipelineBuilder
|
|
109
117
|
end
|
110
118
|
|
111
119
|
def load_collection_from_path(path, recursively = false)
|
120
|
+
path = File.expand_path(path, relative_to=Dir.getwd)
|
112
121
|
if File.directory?(path)
|
113
122
|
@logger.info "Generating from folder #{path}"
|
114
123
|
Dir[File.join(path, '/*.yaml'), File.join(path, '/*.yml')].each do |file|
|
@@ -183,6 +192,7 @@ module JenkinsPipelineBuilder
|
|
183
192
|
job = get_item(name)
|
184
193
|
raise "Failed to locate job by name '#{name}'" if job.nil?
|
185
194
|
job_value = job[:value]
|
195
|
+
@logger.debug "Compiling job #{name}"
|
186
196
|
compiled_job = Compiler.compile(job_value, settings)
|
187
197
|
return compiled_job
|
188
198
|
end
|
@@ -23,16 +23,16 @@ describe JenkinsPipelineBuilder::View do
|
|
23
23
|
def create_and_validate(params)
|
24
24
|
name = params[:name]
|
25
25
|
@valid_post_responses.should include(
|
26
|
-
|
27
|
-
|
26
|
+
@generator.view.create(params).to_i
|
27
|
+
)
|
28
28
|
@generator.view.list_children(params[:parent_view], name).include?(name).should be_true
|
29
29
|
end
|
30
30
|
|
31
31
|
def destroy_and_validate(params)
|
32
32
|
name = params[:name]
|
33
33
|
@valid_post_responses.should include(
|
34
|
-
|
35
|
-
|
34
|
+
@generator.view.delete(name, params[:parent_view]).to_i
|
35
|
+
)
|
36
36
|
@generator.view.list_children(params[:parent_view], name).include?(name).should be_false
|
37
37
|
end
|
38
38
|
|
@@ -43,7 +43,7 @@ describe JenkinsPipelineBuilder::View do
|
|
43
43
|
|
44
44
|
it 'accepts the name of the view and creates the view' do
|
45
45
|
params = {
|
46
|
-
|
46
|
+
:name => 'test_list_view'
|
47
47
|
}
|
48
48
|
|
49
49
|
test_and_validate(params)
|
@@ -51,15 +51,15 @@ describe JenkinsPipelineBuilder::View do
|
|
51
51
|
|
52
52
|
it 'creates a Nested view with a child' do
|
53
53
|
params_parent = {
|
54
|
-
|
55
|
-
|
54
|
+
name: 'My Test Parent View',
|
55
|
+
type: 'nestedView'
|
56
56
|
}
|
57
57
|
|
58
58
|
create_and_validate(params_parent)
|
59
59
|
|
60
60
|
params_child = {
|
61
|
-
|
62
|
-
|
61
|
+
name: 'Test List View',
|
62
|
+
parent_view: params_parent[:name]
|
63
63
|
}
|
64
64
|
|
65
65
|
test_and_validate(params_child)
|
@@ -69,20 +69,20 @@ describe JenkinsPipelineBuilder::View do
|
|
69
69
|
|
70
70
|
it 'creates a categorized view with columns' do
|
71
71
|
params = {
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
72
|
+
name: 'test_category_view',
|
73
|
+
type: 'categorizedView',
|
74
|
+
description: 'Blah blah',
|
75
|
+
regex: 'Job-.*',
|
76
|
+
groupingRules: [{
|
77
|
+
groupRegex: 'Step-1.*',
|
78
|
+
namingRule: '1. Commit'
|
79
|
+
},{
|
80
|
+
groupRegex: 'Step-2.*',
|
81
|
+
namingRule: '2. Acceptance'
|
82
|
+
},{
|
83
|
+
groupRegex: 'Step-3.*',
|
84
|
+
namingRule: '3. Release'
|
85
|
+
}]
|
86
86
|
}
|
87
87
|
|
88
88
|
test_and_validate(params)
|
@@ -90,4 +90,4 @@ describe JenkinsPipelineBuilder::View do
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
93
|
-
end
|
93
|
+
end
|
@@ -68,18 +68,34 @@
|
|
68
68
|
<concurrentBuild>false</concurrentBuild>
|
69
69
|
<builders>
|
70
70
|
<com.tikal.jenkins.plugins.multijob.MultiJobBuilder>
|
71
|
-
<phaseName>
|
71
|
+
<phaseName>Phase One</phaseName>
|
72
72
|
<phaseJobs>
|
73
73
|
<com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
|
74
|
-
<jobName>
|
75
|
-
<currParams>
|
76
|
-
<exposedSCM>
|
74
|
+
<jobName>first</jobName>
|
75
|
+
<currParams>true</currParams>
|
76
|
+
<exposedSCM>true</exposedSCM>
|
77
77
|
<configs>
|
78
78
|
<hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
|
79
79
|
<properties>PARENT_WORKSPACE=${WORKSPACE}</properties>
|
80
80
|
</hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
|
81
81
|
</configs>
|
82
82
|
</com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
|
83
|
+
<com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
|
84
|
+
<jobName>second</jobName>
|
85
|
+
<currParams>false</currParams>
|
86
|
+
<exposedSCM>false</exposedSCM>
|
87
|
+
</com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
|
88
|
+
</phaseJobs>
|
89
|
+
<continuationCondition>COMPLETED</continuationCondition>
|
90
|
+
</com.tikal.jenkins.plugins.multijob.MultiJobBuilder>
|
91
|
+
<com.tikal.jenkins.plugins.multijob.MultiJobBuilder>
|
92
|
+
<phaseName>Phase Two</phaseName>
|
93
|
+
<phaseJobs>
|
94
|
+
<com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
|
95
|
+
<jobName>third</jobName>
|
96
|
+
<currParams>false</currParams>
|
97
|
+
<exposedSCM>false</exposedSCM>
|
98
|
+
</com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
|
83
99
|
</phaseJobs>
|
84
100
|
<continuationCondition>SUCCESSFUL</continuationCondition>
|
85
101
|
</com.tikal.jenkins.plugins.multijob.MultiJobBuilder>
|
@@ -19,10 +19,21 @@
|
|
19
19
|
- git_push: true
|
20
20
|
- scm_polling: "H/5 * * * *"
|
21
21
|
builders:
|
22
|
-
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
- multi_job:
|
23
|
+
phases:
|
24
|
+
"Phase One":
|
25
|
+
jobs:
|
26
|
+
- name: first
|
27
|
+
exposed_scm: true
|
28
|
+
current_params: true
|
29
|
+
config:
|
30
|
+
predefined_build_parameters:
|
31
|
+
- "PARENT_WORKSPACE=${WORKSPACE}"
|
32
|
+
- name: second
|
33
|
+
continue_condition: COMPLETED
|
34
|
+
"Phase Two":
|
35
|
+
jobs:
|
36
|
+
- name: third
|
26
37
|
- inject_vars_file: build_job_info
|
27
38
|
publishers:
|
28
39
|
- downstream:
|
@@ -1,5 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require 'equivalent-xml'
|
1
|
+
require 'unit_tests/spec_helper'
|
3
2
|
|
4
3
|
describe 'Test YAML jobs conversion to XML' do
|
5
4
|
context 'Loading YAML files' do
|
@@ -64,4 +63,4 @@ describe 'Test YAML jobs conversion to XML' do
|
|
64
63
|
end
|
65
64
|
end
|
66
65
|
end
|
67
|
-
end
|
66
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jenkins_pipeline_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Moochnick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -258,6 +258,9 @@ executables:
|
|
258
258
|
extensions: []
|
259
259
|
extra_rdoc_files: []
|
260
260
|
files:
|
261
|
+
- .ackrc
|
262
|
+
- .gitignore
|
263
|
+
- .rspec
|
261
264
|
- .ruby-gemset
|
262
265
|
- .ruby-version
|
263
266
|
- Gemfile
|