rubyjobbuilderdsl 0.0.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 +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +33 -0
- data/LICENSE +19 -0
- data/Rakefile +12 -0
- data/docs/common.md +313 -0
- data/docs/flow.md +18 -0
- data/docs/freestyle.md +100 -0
- data/docs/gerrit.md +70 -0
- data/docs/git.md +88 -0
- data/docs/index.md +11 -0
- data/docs/multi.md +27 -0
- data/docs/overview.md +74 -0
- data/docs/postbuild.md +266 -0
- data/docs/view.md +13 -0
- data/lib/rubyjobbuilderdsl/builder.rb +69 -0
- data/lib/rubyjobbuilderdsl/buildstep/ant.rb +29 -0
- data/lib/rubyjobbuilderdsl/buildstep/copyartifact.rb +23 -0
- data/lib/rubyjobbuilderdsl/buildstep/inject_env.rb +18 -0
- data/lib/rubyjobbuilderdsl/buildstep/phase.rb +19 -0
- data/lib/rubyjobbuilderdsl/buildstep/phase_job.rb +26 -0
- data/lib/rubyjobbuilderdsl/buildstep/shell.rb +24 -0
- data/lib/rubyjobbuilderdsl/common/artifactory.rb +33 -0
- data/lib/rubyjobbuilderdsl/common/blocking_job.rb +11 -0
- data/lib/rubyjobbuilderdsl/common/build_timeout.rb +23 -0
- data/lib/rubyjobbuilderdsl/common/gerrit.rb +53 -0
- data/lib/rubyjobbuilderdsl/common/git.rb +76 -0
- data/lib/rubyjobbuilderdsl/common/logrotate.rb +24 -0
- data/lib/rubyjobbuilderdsl/common/parameter.rb +22 -0
- data/lib/rubyjobbuilderdsl/common/password.rb +12 -0
- data/lib/rubyjobbuilderdsl/common/pollscm.rb +10 -0
- data/lib/rubyjobbuilderdsl/common/scms.rb +18 -0
- data/lib/rubyjobbuilderdsl/common/throttle.rb +24 -0
- data/lib/rubyjobbuilderdsl/common/timed.rb +10 -0
- data/lib/rubyjobbuilderdsl/common/timestamps.rb +6 -0
- data/lib/rubyjobbuilderdsl/common.rb +140 -0
- data/lib/rubyjobbuilderdsl/deployer.rb +95 -0
- data/lib/rubyjobbuilderdsl/flow.rb +14 -0
- data/lib/rubyjobbuilderdsl/freestyle.rb +57 -0
- data/lib/rubyjobbuilderdsl/jenkins_client.rb +203 -0
- data/lib/rubyjobbuilderdsl/multijob.rb +24 -0
- data/lib/rubyjobbuilderdsl/postbuild/archive.rb +23 -0
- data/lib/rubyjobbuilderdsl/postbuild/chucknorris_publisher.rb +6 -0
- data/lib/rubyjobbuilderdsl/postbuild/claim_publisher.rb +6 -0
- data/lib/rubyjobbuilderdsl/postbuild/cloverphp_publisher.rb +36 -0
- data/lib/rubyjobbuilderdsl/postbuild/email_publisher.rb +23 -0
- data/lib/rubyjobbuilderdsl/postbuild/game_publisher.rb +6 -0
- data/lib/rubyjobbuilderdsl/postbuild/groovy.rb +10 -0
- data/lib/rubyjobbuilderdsl/postbuild/html_publisher.rb +27 -0
- data/lib/rubyjobbuilderdsl/postbuild/javadoc_publisher.rb +19 -0
- data/lib/rubyjobbuilderdsl/postbuild/logparser.rb +21 -0
- data/lib/rubyjobbuilderdsl/postbuild/nunit_publisher.rb +21 -0
- data/lib/rubyjobbuilderdsl/postbuild/pmd_publisher.rb +19 -0
- data/lib/rubyjobbuilderdsl/postbuild/script.rb +14 -0
- data/lib/rubyjobbuilderdsl/postbuild/tap_publisher.rb +44 -0
- data/lib/rubyjobbuilderdsl/postbuild/trigger.rb +38 -0
- data/lib/rubyjobbuilderdsl/postbuild/xunit_publisher.rb +35 -0
- data/lib/rubyjobbuilderdsl/postbuild.rb +146 -0
- data/lib/rubyjobbuilderdsl/view.rb +14 -0
- data/lib/rubyjobbuilderdsl/xml_generator.rb +839 -0
- data/lib/rubyjobbuilderdsl.rb +2 -0
- data/rubyjobbuilderdsl.gemspec +13 -0
- data/rubyjobbuilderdsl.sublime-project +14 -0
- data/run_tests.sh +7 -0
- data/sample/hello_mars.rb +27 -0
- data/sample/local.ini +4 -0
- data/test/test_ant.rb +38 -0
- data/test/test_archive.rb +24 -0
- data/test/test_artifactory.rb +26 -0
- data/test/test_blocking_job.rb +18 -0
- data/test/test_chucknorris_publisher.rb +17 -0
- data/test/test_claim_publisher.rb +17 -0
- data/test/test_cloverphp.rb +33 -0
- data/test/test_concurrent.rb +44 -0
- data/test/test_copyartifact.rb +45 -0
- data/test/test_default_setting.rb +29 -0
- data/test/test_email_publisher.rb +44 -0
- data/test/test_flow.rb +19 -0
- data/test/test_freestyle.rb +52 -0
- data/test/test_game_publisher.rb +17 -0
- data/test/test_gerrit.rb +117 -0
- data/test/test_git.rb +80 -0
- data/test/test_html_publisher.rb +57 -0
- data/test/test_inject.rb +23 -0
- data/test/test_javadoc.rb +22 -0
- data/test/test_logparser.rb +24 -0
- data/test/test_logrotate.rb +22 -0
- data/test/test_multijob.rb +50 -0
- data/test/test_nunit_publisher.rb +20 -0
- data/test/test_parameter.rb +44 -0
- data/test/test_password.rb +17 -0
- data/test/test_pmd.rb +22 -0
- data/test/test_pollscm.rb +15 -0
- data/test/test_postbuild_groovy.rb +21 -0
- data/test/test_postbuild_script.rb +24 -0
- data/test/test_postbuild_trigger.rb +170 -0
- data/test/test_scms.rb +31 -0
- data/test/test_tap_publisher.rb +25 -0
- data/test/test_timed.rb +15 -0
- data/test/test_timeout.rb +20 -0
- data/test/test_timestamps.rb +14 -0
- data/test/test_xml_generator.rb +28 -0
- data/test/test_xunit_publisher.rb +22 -0
- metadata +173 -0
data/docs/overview.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
## Overview
|
|
2
|
+
|
|
3
|
+
The Openstack Job Builder python project use YAML as input for job creation. It is huge step from creating job using XML or even worse UI.
|
|
4
|
+
However YAML has limitation lacking of both composition and abstraction causing repetitive work and maintenance issue . It may well suit for
|
|
5
|
+
creating of dozen of jobs but not hundreds similar jobs. This is driving factor for creation of Ruby Job Builder DSL.
|
|
6
|
+
|
|
7
|
+
Ruby Jobs Builder DSL is ruby internal DSL, so it offers full fledged programming experience at the same time concise, focused vocabulary
|
|
8
|
+
for job creation.
|
|
9
|
+
|
|
10
|
+
Ruby Jobs Builder DSL can
|
|
11
|
+
|
|
12
|
+
* generate Jenkins XML job configuration files
|
|
13
|
+
* deploy jobs directly into Jenkins Server
|
|
14
|
+
|
|
15
|
+
## Example
|
|
16
|
+
|
|
17
|
+
Step 1 - Create a ruby file e.g. hello-world.rb with the following content
|
|
18
|
+
|
|
19
|
+
# hello-world.rb
|
|
20
|
+
require 'rubyjobbuilderdsl'
|
|
21
|
+
builder = JenkinsJob::Builder.new
|
|
22
|
+
builder.freestyle 'hello-world' do
|
|
23
|
+
shell 'echo hello world'
|
|
24
|
+
end
|
|
25
|
+
JenkinsJob::Deployer.new(builder).run
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
Step 2 - Run it
|
|
29
|
+
|
|
30
|
+
$bundle exec ruby hello-world.rb
|
|
31
|
+
Usage:
|
|
32
|
+
hello-world.rb [--xml --output-dir=.|--deploy --config-file=localhost.ini]
|
|
33
|
+
|
|
34
|
+
Step 3 - Create XML
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
sh-3.1$ bundle exec ruby hello_world.rb --xml --output-dir=.
|
|
38
|
+
creating hello-world
|
|
39
|
+
sh-3.1$ cat hello-world.xml
|
|
40
|
+
<project>
|
|
41
|
+
<actions/>
|
|
42
|
+
<description><!-- Managed by Jenkins Job Builder --></description>
|
|
43
|
+
<keepDependencies>false</keepDependencies>
|
|
44
|
+
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
|
45
|
+
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
|
46
|
+
<concurrentBuild>false</concurrentBuild>
|
|
47
|
+
<canRoam>true</canRoam>
|
|
48
|
+
<properties/>
|
|
49
|
+
<scm class="hudson.scm.NullSCM"/>
|
|
50
|
+
<publishers/>
|
|
51
|
+
<buildWrappers/>
|
|
52
|
+
<builders>
|
|
53
|
+
<hudson.tasks.Shell>
|
|
54
|
+
<command>echo hello world</command>
|
|
55
|
+
</hudson.tasks.Shell>
|
|
56
|
+
</builders>
|
|
57
|
+
</project>
|
|
58
|
+
|
|
59
|
+
Step 4 - Upload the created job to your Jenkins server
|
|
60
|
+
|
|
61
|
+
sh-3.1$ cat localhost.ini
|
|
62
|
+
[jenkins]
|
|
63
|
+
url=http://localhost:8080/
|
|
64
|
+
user=jenkins-jobs
|
|
65
|
+
password=7bb352e4f3da683c17247f3abf88f47c
|
|
66
|
+
|
|
67
|
+
sh-3.1$ bundle exec ruby hello_world.rb --deploy ----config-file=localhost.ini
|
|
68
|
+
deploying hello-world
|
|
69
|
+
|
|
70
|
+
## References
|
|
71
|
+
|
|
72
|
+
* http://ci.openstack.org/jenkins-job-builder/
|
|
73
|
+
* https://github.com/jenkinsci/jenkins.rb
|
|
74
|
+
* https://github.com/jenkinsci/job-dsl-plugin/wiki/Job-DSL-Commands
|
data/docs/postbuild.md
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
## Configure post build activities
|
|
2
|
+
|
|
3
|
+
**allow_broken_build_claiming**
|
|
4
|
+
|
|
5
|
+
Description: Allow developer to claim for broken build
|
|
6
|
+
|
|
7
|
+
Multiple: Override
|
|
8
|
+
|
|
9
|
+
Example
|
|
10
|
+
|
|
11
|
+
builder.freestyle 'hello_world-build' do
|
|
12
|
+
postbuild do
|
|
13
|
+
allow_broken_build_claiming
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
**archive**
|
|
18
|
+
|
|
19
|
+
Description: Archive artifacts
|
|
20
|
+
|
|
21
|
+
Multiple: Override
|
|
22
|
+
|
|
23
|
+
Example
|
|
24
|
+
|
|
25
|
+
builder.freestyle 'hello_world-master' do
|
|
26
|
+
postbuild do
|
|
27
|
+
archive do
|
|
28
|
+
file 'package/**',
|
|
29
|
+
'output/**',
|
|
30
|
+
'dependencies/lib/**'
|
|
31
|
+
latest_only true
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
**chucknorris**
|
|
37
|
+
|
|
38
|
+
Description: Show Chuck Norris Image
|
|
39
|
+
|
|
40
|
+
Multiple: Override
|
|
41
|
+
|
|
42
|
+
Example
|
|
43
|
+
|
|
44
|
+
builder.freestyle 'hello_world-build' do
|
|
45
|
+
postbuild do
|
|
46
|
+
chucknorris
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
**game**
|
|
51
|
+
|
|
52
|
+
Description: Enable CI Game
|
|
53
|
+
|
|
54
|
+
Multiple: Override
|
|
55
|
+
|
|
56
|
+
Example
|
|
57
|
+
|
|
58
|
+
builder.freestyle 'hello_world-build' do
|
|
59
|
+
postbuild do
|
|
60
|
+
game
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
**groovy**
|
|
65
|
+
|
|
66
|
+
Description: Run groovy script
|
|
67
|
+
|
|
68
|
+
Multiple: Override
|
|
69
|
+
|
|
70
|
+
Example
|
|
71
|
+
|
|
72
|
+
builder.freestyle 'hello_world-build' do
|
|
73
|
+
postbuild do
|
|
74
|
+
groovy <<EOS
|
|
75
|
+
def logger = manager.listener.logger
|
|
76
|
+
logger.println("--- Hello World")
|
|
77
|
+
EOS
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
**logparser**
|
|
82
|
+
|
|
83
|
+
Description: Parse console log to highlight errors
|
|
84
|
+
|
|
85
|
+
Multiple: Override
|
|
86
|
+
|
|
87
|
+
Example
|
|
88
|
+
|
|
89
|
+
builder.freestyle 'hello_world-build' do
|
|
90
|
+
postbuild do
|
|
91
|
+
logparser '/var/lib/jenkins/build_parsing_rules' do
|
|
92
|
+
fail_on_error
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
**pubish_pmd**
|
|
98
|
+
|
|
99
|
+
Description: Publish PMD analysis
|
|
100
|
+
|
|
101
|
+
Multiple: Override
|
|
102
|
+
|
|
103
|
+
Example
|
|
104
|
+
|
|
105
|
+
builder.freestyle 'hello_world' do
|
|
106
|
+
postbuild do
|
|
107
|
+
publish_pmd do
|
|
108
|
+
pmd_results 'build/phppmd.txt'
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
**publish_cloverphp**
|
|
114
|
+
|
|
115
|
+
Description: Publish clover php analysis
|
|
116
|
+
|
|
117
|
+
Multiple: Override
|
|
118
|
+
|
|
119
|
+
Example
|
|
120
|
+
|
|
121
|
+
builder.freestyle 'hello_world' do
|
|
122
|
+
postbuild do
|
|
123
|
+
publish_cloverphp do
|
|
124
|
+
xml_location 'build/coverage_clover.xml'
|
|
125
|
+
html_report_dir 'build/coverage'
|
|
126
|
+
healthy_target :method => 70, :statement => 80
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
**publish_html**
|
|
132
|
+
|
|
133
|
+
Description: Publish html report
|
|
134
|
+
|
|
135
|
+
Multiple: Override
|
|
136
|
+
|
|
137
|
+
Example
|
|
138
|
+
|
|
139
|
+
builder.freestyle 'hello_world-servicetest' do
|
|
140
|
+
postbuild do
|
|
141
|
+
publish_html 'Test Report' do
|
|
142
|
+
dir '$BUILD_NUMBER\\Reports'
|
|
143
|
+
file 'test-report.html'
|
|
144
|
+
keep_all false
|
|
145
|
+
allow_missing true
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
**publish_javadoc**
|
|
151
|
+
|
|
152
|
+
Description: Publish javadoc
|
|
153
|
+
|
|
154
|
+
Multiple: Override
|
|
155
|
+
|
|
156
|
+
Example
|
|
157
|
+
|
|
158
|
+
builder.freestyle 'hello_world-build' do
|
|
159
|
+
postbuild do
|
|
160
|
+
publish_javadoc do
|
|
161
|
+
doc_dir 'build/doc'
|
|
162
|
+
keep_all
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
**publish_nunit_report**
|
|
168
|
+
|
|
169
|
+
Description: Publish NUnit test results.
|
|
170
|
+
|
|
171
|
+
Multiple: Override
|
|
172
|
+
|
|
173
|
+
Example
|
|
174
|
+
|
|
175
|
+
builder.freestyle 'hello_world-build' do
|
|
176
|
+
postbuild do
|
|
177
|
+
publish_nunit_report 'foo\\bar\\*.xml'
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
**publish_tap**
|
|
182
|
+
|
|
183
|
+
Description: Publish TAP test result
|
|
184
|
+
|
|
185
|
+
Multiple: Override
|
|
186
|
+
|
|
187
|
+
Example
|
|
188
|
+
|
|
189
|
+
builder.freestyle 'hello_world-build' do
|
|
190
|
+
postbuild do
|
|
191
|
+
publish_tap 'TestResultsInTapFormat.tap' do
|
|
192
|
+
verbose true
|
|
193
|
+
require_plan true
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
**publish_xunit_report**
|
|
199
|
+
|
|
200
|
+
Description: Publish XUnit test results
|
|
201
|
+
|
|
202
|
+
Multiple: Override
|
|
203
|
+
|
|
204
|
+
Example
|
|
205
|
+
|
|
206
|
+
builder.freestyle 'hello_world-build' do
|
|
207
|
+
postbuild do
|
|
208
|
+
publish_xunit_report 'foo\\bar\\*.xml' do
|
|
209
|
+
failed_threshold :total_failed_tests => 0, :new_failed_tests => 0
|
|
210
|
+
unstable_threshold :total_skipped_tests => 0, :new_skipped_tests => 0
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
**send_email**
|
|
216
|
+
|
|
217
|
+
Description: Send notification via email
|
|
218
|
+
|
|
219
|
+
Multiple: Override
|
|
220
|
+
|
|
221
|
+
Example
|
|
222
|
+
|
|
223
|
+
builder.freestyle 'hello_world-build' do
|
|
224
|
+
postbuild do
|
|
225
|
+
send_email 'test@example.com' do
|
|
226
|
+
notify_every_unstable_build false
|
|
227
|
+
send_to_individuals true
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
**shell**
|
|
233
|
+
|
|
234
|
+
Description: Run shell command in as a post build action
|
|
235
|
+
|
|
236
|
+
Multiple: Override
|
|
237
|
+
|
|
238
|
+
Example
|
|
239
|
+
|
|
240
|
+
builder.freestyle 'hello_world-build' do
|
|
241
|
+
postbuild do
|
|
242
|
+
shell 'cd Reports && mv $(ls *.xml) merge.xml'
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
**trigger**
|
|
247
|
+
|
|
248
|
+
Description: Trigger other job when this build succeeds
|
|
249
|
+
|
|
250
|
+
Multiple: Override
|
|
251
|
+
|
|
252
|
+
Example
|
|
253
|
+
|
|
254
|
+
builder.freestyle 'hello_world-build' do
|
|
255
|
+
postbuild do
|
|
256
|
+
trigger 'foo-build', 'bar-build' do
|
|
257
|
+
fail_on_missing true
|
|
258
|
+
current_parameters true
|
|
259
|
+
file 'env.properties'
|
|
260
|
+
predefined_parameters 'BUILD_NUM' => '${BUILD_NUMBER}',
|
|
261
|
+
'PACKAGE_VERSION' => '${PACKAGE_VERSION}'
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
|
data/docs/view.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require_relative 'freestyle'
|
|
2
|
+
require_relative 'flow'
|
|
3
|
+
require_relative 'multijob'
|
|
4
|
+
require_relative 'view'
|
|
5
|
+
require_relative 'xml_generator'
|
|
6
|
+
|
|
7
|
+
module JenkinsJob
|
|
8
|
+
# dsl methods for job builder
|
|
9
|
+
class Builder
|
|
10
|
+
attr_reader :jobs, :views
|
|
11
|
+
|
|
12
|
+
def initialize(&block)
|
|
13
|
+
@default_setting = []
|
|
14
|
+
@default_setting << block if block_given?
|
|
15
|
+
@jobs = {}
|
|
16
|
+
@views = {}
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def add_extension(&block)
|
|
20
|
+
@default_setting << block if block_given?
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def freestyle(name, &block)
|
|
24
|
+
@jobs[name] = FreeStyle.new(name, self)
|
|
25
|
+
|
|
26
|
+
@default_setting.each do |extension|
|
|
27
|
+
@jobs[name].instance_eval(&extension)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
@jobs[name].instance_eval(&block)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def flow(name, &block)
|
|
34
|
+
@jobs[name] = Flow.new(name, self)
|
|
35
|
+
|
|
36
|
+
@default_setting.each do |extension|
|
|
37
|
+
@jobs[name].instance_eval(&extension)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
@jobs[name].instance_eval(&block)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def multi(name, &block)
|
|
44
|
+
@jobs[name] = MultiJob.new(name, self)
|
|
45
|
+
|
|
46
|
+
@default_setting.each do |extension|
|
|
47
|
+
@jobs[name].instance_eval(&extension)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
@jobs[name].instance_eval(&block)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def view(name, &block)
|
|
54
|
+
@views[name] = View.new(name, self)
|
|
55
|
+
@views[name].instance_eval(&block)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def generate_xml
|
|
59
|
+
return unless block_given?
|
|
60
|
+
generator = XmlGenerator.new
|
|
61
|
+
@jobs.each do |name, job|
|
|
62
|
+
yield name, generator.generate(job), :job
|
|
63
|
+
end
|
|
64
|
+
@views.each do |name, job|
|
|
65
|
+
yield name, generator.generate(job), :view
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module JenkinsJob
|
|
2
|
+
module BuildStep
|
|
3
|
+
class Ant < BasicObject
|
|
4
|
+
attr_reader :targets_, :buildfile_, :properties_, :java_opts_
|
|
5
|
+
|
|
6
|
+
def initialize
|
|
7
|
+
@targets_ = []
|
|
8
|
+
@properties_ = {}
|
|
9
|
+
@java_opts_ = []
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def target(*value)
|
|
13
|
+
@targets_ = value
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def buildfile(value)
|
|
17
|
+
@buildfile_ = value
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def property(value)
|
|
21
|
+
@properties_ = value
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def java_opts(*value)
|
|
25
|
+
@java_opts_ = value
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module JenkinsJob
|
|
2
|
+
module BuildStep
|
|
3
|
+
class CopyArtifact < BasicObject
|
|
4
|
+
attr_reader :project_, :filter_, :target_, :build_number_
|
|
5
|
+
|
|
6
|
+
def initialize(artifact_job)
|
|
7
|
+
@project_ = artifact_job
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def file(*files)
|
|
11
|
+
@filter_ = files.join(',')
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to(dir)
|
|
15
|
+
@target_ = dir
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def build_number(value = nil)
|
|
19
|
+
@build_number_ = value
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module JenkinsJob
|
|
2
|
+
module BuildStep
|
|
3
|
+
class InjectEnv < BasicObject
|
|
4
|
+
attr_reader :properties_content_, :properties_file_
|
|
5
|
+
|
|
6
|
+
def initialize
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def properties_content(value)
|
|
10
|
+
@properties_content_ = value
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def properties_file(value)
|
|
14
|
+
@properties_file_ = value
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module JenkinsJob
|
|
2
|
+
module BuildStep
|
|
3
|
+
class Phase < BasicObject
|
|
4
|
+
attr_reader :name, :jobs_
|
|
5
|
+
|
|
6
|
+
def initialize(name)
|
|
7
|
+
@name = name
|
|
8
|
+
@jobs_ = []
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def job(name, &block)
|
|
12
|
+
job = PhaseJob.new(name)
|
|
13
|
+
job.instance_eval(&block) if block
|
|
14
|
+
|
|
15
|
+
@jobs_ << job
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module JenkinsJob
|
|
2
|
+
module BuildStep
|
|
3
|
+
class PhaseJob < BasicObject
|
|
4
|
+
attr_reader :name, :ignore_result_, :retries_, :abort_others_
|
|
5
|
+
|
|
6
|
+
def initialize(name)
|
|
7
|
+
@name = name
|
|
8
|
+
@ignore_result_ = false
|
|
9
|
+
@retries_ = 0
|
|
10
|
+
@abort_others_ = false
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def ignore_result(value = true)
|
|
14
|
+
@ignore_result_ = value
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def retries(value)
|
|
18
|
+
@retries_ = value
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def abort_others(value = true)
|
|
22
|
+
@abort_others_ = value
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module JenkinsJob
|
|
2
|
+
module BuildStep
|
|
3
|
+
class Shell < BasicObject
|
|
4
|
+
attr_reader :cmd_
|
|
5
|
+
def initialize(cmd)
|
|
6
|
+
@cmd_ = cmd
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class Batch < BasicObject
|
|
11
|
+
attr_reader :cmd_
|
|
12
|
+
def initialize(cmd)
|
|
13
|
+
@cmd_ = cmd
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class Powershell < BasicObject
|
|
18
|
+
attr_reader :cmd_
|
|
19
|
+
def initialize(cmd)
|
|
20
|
+
@cmd_ = cmd
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module JenkinsJob
|
|
2
|
+
module Common
|
|
3
|
+
class Artifactory < BasicObject
|
|
4
|
+
attr_reader :server_, :repository_, :deploy_, :resolve_, :build_info_
|
|
5
|
+
|
|
6
|
+
def initialize
|
|
7
|
+
@deploy_ = []
|
|
8
|
+
@resolve_ = []
|
|
9
|
+
@build_info_ = false
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def server(value)
|
|
13
|
+
@server_ = value
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def repository(value)
|
|
17
|
+
@repository_ = value
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def deploy(*value)
|
|
21
|
+
@deploy_ = value
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def resolve(*value)
|
|
25
|
+
@resolve_ = value
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def build_info(value = true)
|
|
29
|
+
@build_info_ = value
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module JenkinsJob
|
|
2
|
+
module Common
|
|
3
|
+
class BuildTimeout < BasicObject
|
|
4
|
+
attr_reader :type_, :timeout_, :elastic_percentage_, :elastic_default_timeout_
|
|
5
|
+
|
|
6
|
+
def initialize(type)
|
|
7
|
+
@type_ = type
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def timeout(value)
|
|
11
|
+
@timeout_ = value
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def elastic_percentage(value)
|
|
15
|
+
@elastic_percentage_ = value
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def elastic_default_timeout(value)
|
|
19
|
+
@elastic_default_timeout_ = value
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module JenkinsJob
|
|
2
|
+
module Common
|
|
3
|
+
class Gerrit < BasicObject
|
|
4
|
+
attr_reader :change_merged_, :patchset_uploaded_, :comment_added_, :projects_
|
|
5
|
+
|
|
6
|
+
def initialize
|
|
7
|
+
@comment_added_ = []
|
|
8
|
+
@projects_ = []
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def change_merged(value = true)
|
|
12
|
+
@change_merged_ = value
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def patchset_uploaded(value = true)
|
|
16
|
+
@patchset_uploaded_ = value
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def comment_added(param = {})
|
|
20
|
+
param.each do |k, v|
|
|
21
|
+
@comment_added_ << {
|
|
22
|
+
:approval_category => k,
|
|
23
|
+
:approval_value => v
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def project(project, &block)
|
|
29
|
+
project = GerritProject.new(project)
|
|
30
|
+
project.instance_eval(&block)
|
|
31
|
+
|
|
32
|
+
@projects_ << project
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class GerritProject < BasicObject
|
|
37
|
+
attr_reader :project_, :branches_, :files_
|
|
38
|
+
|
|
39
|
+
def initialize(project)
|
|
40
|
+
@project_ = project
|
|
41
|
+
@branches_ = ['**']
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def branch(*value)
|
|
45
|
+
@branches_ = value
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def file(*value)
|
|
49
|
+
@files_ = value
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|