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.
Files changed (104) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +6 -0
  3. data/Gemfile.lock +33 -0
  4. data/LICENSE +19 -0
  5. data/Rakefile +12 -0
  6. data/docs/common.md +313 -0
  7. data/docs/flow.md +18 -0
  8. data/docs/freestyle.md +100 -0
  9. data/docs/gerrit.md +70 -0
  10. data/docs/git.md +88 -0
  11. data/docs/index.md +11 -0
  12. data/docs/multi.md +27 -0
  13. data/docs/overview.md +74 -0
  14. data/docs/postbuild.md +266 -0
  15. data/docs/view.md +13 -0
  16. data/lib/rubyjobbuilderdsl/builder.rb +69 -0
  17. data/lib/rubyjobbuilderdsl/buildstep/ant.rb +29 -0
  18. data/lib/rubyjobbuilderdsl/buildstep/copyartifact.rb +23 -0
  19. data/lib/rubyjobbuilderdsl/buildstep/inject_env.rb +18 -0
  20. data/lib/rubyjobbuilderdsl/buildstep/phase.rb +19 -0
  21. data/lib/rubyjobbuilderdsl/buildstep/phase_job.rb +26 -0
  22. data/lib/rubyjobbuilderdsl/buildstep/shell.rb +24 -0
  23. data/lib/rubyjobbuilderdsl/common/artifactory.rb +33 -0
  24. data/lib/rubyjobbuilderdsl/common/blocking_job.rb +11 -0
  25. data/lib/rubyjobbuilderdsl/common/build_timeout.rb +23 -0
  26. data/lib/rubyjobbuilderdsl/common/gerrit.rb +53 -0
  27. data/lib/rubyjobbuilderdsl/common/git.rb +76 -0
  28. data/lib/rubyjobbuilderdsl/common/logrotate.rb +24 -0
  29. data/lib/rubyjobbuilderdsl/common/parameter.rb +22 -0
  30. data/lib/rubyjobbuilderdsl/common/password.rb +12 -0
  31. data/lib/rubyjobbuilderdsl/common/pollscm.rb +10 -0
  32. data/lib/rubyjobbuilderdsl/common/scms.rb +18 -0
  33. data/lib/rubyjobbuilderdsl/common/throttle.rb +24 -0
  34. data/lib/rubyjobbuilderdsl/common/timed.rb +10 -0
  35. data/lib/rubyjobbuilderdsl/common/timestamps.rb +6 -0
  36. data/lib/rubyjobbuilderdsl/common.rb +140 -0
  37. data/lib/rubyjobbuilderdsl/deployer.rb +95 -0
  38. data/lib/rubyjobbuilderdsl/flow.rb +14 -0
  39. data/lib/rubyjobbuilderdsl/freestyle.rb +57 -0
  40. data/lib/rubyjobbuilderdsl/jenkins_client.rb +203 -0
  41. data/lib/rubyjobbuilderdsl/multijob.rb +24 -0
  42. data/lib/rubyjobbuilderdsl/postbuild/archive.rb +23 -0
  43. data/lib/rubyjobbuilderdsl/postbuild/chucknorris_publisher.rb +6 -0
  44. data/lib/rubyjobbuilderdsl/postbuild/claim_publisher.rb +6 -0
  45. data/lib/rubyjobbuilderdsl/postbuild/cloverphp_publisher.rb +36 -0
  46. data/lib/rubyjobbuilderdsl/postbuild/email_publisher.rb +23 -0
  47. data/lib/rubyjobbuilderdsl/postbuild/game_publisher.rb +6 -0
  48. data/lib/rubyjobbuilderdsl/postbuild/groovy.rb +10 -0
  49. data/lib/rubyjobbuilderdsl/postbuild/html_publisher.rb +27 -0
  50. data/lib/rubyjobbuilderdsl/postbuild/javadoc_publisher.rb +19 -0
  51. data/lib/rubyjobbuilderdsl/postbuild/logparser.rb +21 -0
  52. data/lib/rubyjobbuilderdsl/postbuild/nunit_publisher.rb +21 -0
  53. data/lib/rubyjobbuilderdsl/postbuild/pmd_publisher.rb +19 -0
  54. data/lib/rubyjobbuilderdsl/postbuild/script.rb +14 -0
  55. data/lib/rubyjobbuilderdsl/postbuild/tap_publisher.rb +44 -0
  56. data/lib/rubyjobbuilderdsl/postbuild/trigger.rb +38 -0
  57. data/lib/rubyjobbuilderdsl/postbuild/xunit_publisher.rb +35 -0
  58. data/lib/rubyjobbuilderdsl/postbuild.rb +146 -0
  59. data/lib/rubyjobbuilderdsl/view.rb +14 -0
  60. data/lib/rubyjobbuilderdsl/xml_generator.rb +839 -0
  61. data/lib/rubyjobbuilderdsl.rb +2 -0
  62. data/rubyjobbuilderdsl.gemspec +13 -0
  63. data/rubyjobbuilderdsl.sublime-project +14 -0
  64. data/run_tests.sh +7 -0
  65. data/sample/hello_mars.rb +27 -0
  66. data/sample/local.ini +4 -0
  67. data/test/test_ant.rb +38 -0
  68. data/test/test_archive.rb +24 -0
  69. data/test/test_artifactory.rb +26 -0
  70. data/test/test_blocking_job.rb +18 -0
  71. data/test/test_chucknorris_publisher.rb +17 -0
  72. data/test/test_claim_publisher.rb +17 -0
  73. data/test/test_cloverphp.rb +33 -0
  74. data/test/test_concurrent.rb +44 -0
  75. data/test/test_copyartifact.rb +45 -0
  76. data/test/test_default_setting.rb +29 -0
  77. data/test/test_email_publisher.rb +44 -0
  78. data/test/test_flow.rb +19 -0
  79. data/test/test_freestyle.rb +52 -0
  80. data/test/test_game_publisher.rb +17 -0
  81. data/test/test_gerrit.rb +117 -0
  82. data/test/test_git.rb +80 -0
  83. data/test/test_html_publisher.rb +57 -0
  84. data/test/test_inject.rb +23 -0
  85. data/test/test_javadoc.rb +22 -0
  86. data/test/test_logparser.rb +24 -0
  87. data/test/test_logrotate.rb +22 -0
  88. data/test/test_multijob.rb +50 -0
  89. data/test/test_nunit_publisher.rb +20 -0
  90. data/test/test_parameter.rb +44 -0
  91. data/test/test_password.rb +17 -0
  92. data/test/test_pmd.rb +22 -0
  93. data/test/test_pollscm.rb +15 -0
  94. data/test/test_postbuild_groovy.rb +21 -0
  95. data/test/test_postbuild_script.rb +24 -0
  96. data/test/test_postbuild_trigger.rb +170 -0
  97. data/test/test_scms.rb +31 -0
  98. data/test/test_tap_publisher.rb +25 -0
  99. data/test/test_timed.rb +15 -0
  100. data/test/test_timeout.rb +20 -0
  101. data/test/test_timestamps.rb +14 -0
  102. data/test/test_xml_generator.rb +28 -0
  103. data/test/test_xunit_publisher.rb +22 -0
  104. metadata +173 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eac6041f8878316fe6dc9b31efe8c10e7e9a5052
4
+ data.tar.gz: bb0098789a8d93682b6124dead0368e0c8562682
5
+ SHA512:
6
+ metadata.gz: 0dfd698fdef592c9298c20d11fee0c067e7298e8c21d5bb4cae081d237158dd839876b9a38f83a7d63ee89e213e9f157ce1da5c98de124b1046189a343e60202
7
+ data.tar.gz: 6d4816f9cc97473da9369642618ba143d32fd575626aefbb1108b7dc98385116562dc27aced26436f22f2fa9f223e151e533d3d69d0503c2225e698b18e90a97
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rubocop'
4
+ gem 'builder'
5
+ gem 'nokogiri'
6
+ gem 'rake'
data/Gemfile.lock ADDED
@@ -0,0 +1,33 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ ast (2.0.0)
5
+ astrolabe (1.3.0)
6
+ parser (>= 2.2.0.pre.3, < 3.0)
7
+ builder (3.2.2)
8
+ mini_portile (0.6.0)
9
+ nokogiri (1.6.3.1)
10
+ mini_portile (= 0.6.0)
11
+ parser (2.2.0.pre.4)
12
+ ast (>= 1.1, < 3.0)
13
+ slop (~> 3.4, >= 3.4.5)
14
+ powerpack (0.0.9)
15
+ rainbow (2.0.0)
16
+ rake (0.9.6)
17
+ rubocop (0.26.0)
18
+ astrolabe (~> 1.3)
19
+ parser (>= 2.2.0.pre.4, < 3.0)
20
+ powerpack (~> 0.0.6)
21
+ rainbow (>= 1.99.1, < 3.0)
22
+ ruby-progressbar (~> 1.4)
23
+ ruby-progressbar (1.5.1)
24
+ slop (3.6.0)
25
+
26
+ PLATFORMS
27
+ x86-mingw32
28
+
29
+ DEPENDENCIES
30
+ builder
31
+ nokogiri
32
+ rake
33
+ rubocop
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2014 Wonga
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'rake/testtask'
2
+ require 'rubocop/rake_task'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ t.test_files = FileList['test/test*.rb']
7
+ t.verbose = true
8
+ end
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task :default => [:rubocop, :test]
data/docs/common.md ADDED
@@ -0,0 +1,313 @@
1
+ ## Common vocabulary
2
+
3
+ Common keywords are applicable for both freestyle job and flow job.
4
+
5
+ **artifactory**
6
+
7
+ Description: Deploy artifacts to jfrog artifactory server
8
+
9
+ Multiple: Override
10
+
11
+ Example
12
+
13
+ builder.freestyle 'hello_world-build' do
14
+ artifactory do
15
+ server 'artifactory.acme.com'
16
+ repository 'dev'
17
+ deploy 'hello_world-1.0.$BUILD_NUMBER.zip'
18
+ end
19
+ end
20
+
21
+ **blocked_by**
22
+
23
+ Description: Block build if certain specified jobs are running
24
+
25
+ Multiple: Add
26
+
27
+ Example
28
+
29
+ builder.freestyle 'hello_world-deploy' do
30
+ blocked_by 'hello_world-sevicetest'
31
+ end
32
+
33
+ **Builder**
34
+
35
+ Description: We create builder instance that will be used later to build jobs
36
+
37
+ Multiple: N/A
38
+
39
+ Example
40
+
41
+ require 'rubyjobbuilderdsl'
42
+ builder = JenkinsJob::Builder.new
43
+
44
+ **concurrent**
45
+
46
+ Description: Specify condition for multiple builds of the same job to run concurrently across all nodes of the same category
47
+
48
+ Multiple: Override
49
+
50
+ Example
51
+
52
+ builder.freestyle 'hello_world-servicetest' do
53
+ concurrent do
54
+ max_per_node 1
55
+ max_total 0
56
+ category 'servicetest'
57
+ end
58
+ end
59
+
60
+ **concurrent**
61
+
62
+ Description: Specify condition for multiple builds of the same job to run concurrently across all nodes of the same project
63
+
64
+ Multiple: Override
65
+
66
+ Example
67
+
68
+ builder.freestyle 'hello_world-build' do
69
+ concurrent do
70
+ max_per_node 2
71
+ max_total 0
72
+ end
73
+ end
74
+
75
+ **Deployer**
76
+
77
+ Description: We create deployer instance that will be used to generate/deploy jobs config
78
+
79
+ Multiple: N/A
80
+
81
+ Example
82
+
83
+ require 'rubyjobbuilderdsl'
84
+ check_builder = JenkinsJob::Builder.new
85
+ worker_builder = JenkinsJob::Builder.new
86
+ JenkinsJob::Deployer.new(check_builder, worker_builder).run
87
+
88
+
89
+ **Desc**
90
+
91
+ Description: Specify project's description
92
+
93
+ Multiple: Override
94
+
95
+ Example
96
+
97
+ builder.freestyle 'hello_world-build' do
98
+ desc 'this is a hello world project'
99
+ end
100
+
101
+ **flow**
102
+
103
+ Description: Add Create a flow job
104
+
105
+ Multiple: Add
106
+
107
+ Example
108
+
109
+ builder.flow 'hello_world-check' do
110
+ end
111
+
112
+ **freestyle**
113
+
114
+ Description: Add Create a freestyle job
115
+
116
+ Multiple: Add
117
+
118
+ Example
119
+
120
+ builder.freestyle 'hello_world-build' do
121
+ end
122
+
123
+ **gerrit**
124
+
125
+ Description: trigger the job on Gerrit event
126
+
127
+ Multiple: Override
128
+
129
+ Example
130
+
131
+ builder.flow 'hello_world-post' do
132
+ gerrit do
133
+ end
134
+ end
135
+
136
+
137
+ **git**
138
+
139
+ Description: Configure Git version as SCM
140
+
141
+ Multiple: Override
142
+
143
+ Example:
144
+
145
+ builder.freestyle 'hello_world-master' do
146
+ git do
147
+ end
148
+ end
149
+
150
+ **logrotate**
151
+
152
+ Description: Rotate/discard old builds
153
+
154
+ Multiple: Override
155
+
156
+ Example:
157
+
158
+ builder.freestyle 'hello_world-master' do
159
+ logrotate do
160
+ days_to_keep 14
161
+ num_to_keep -1
162
+ artifact_days_to_keep 2
163
+ artifact_num_to_keep -1
164
+ end
165
+ end
166
+
167
+ **node**
168
+
169
+ Description: Run a job on specific node or kind of nodes
170
+
171
+ Multiple: Override
172
+
173
+ Example:
174
+
175
+ builder.freestyle 'hello_world-build' do
176
+ node 'windows'
177
+ end
178
+
179
+ **parameter**
180
+
181
+ Description: Create parameter for a job
182
+
183
+ Multiple: Add
184
+
185
+ Example:
186
+
187
+ builder.freestyle 'hello_world-check' do
188
+ parameter 'GERRIT_BRANCH' do
189
+ default 'master'
190
+ end
191
+ parameter 'GERRIT_REFSPEC' do
192
+ default 'refs/heads/${GERRIT_BRANCH}'
193
+ end
194
+ end
195
+
196
+ **password**
197
+
198
+ Description: Specify password encrypted by jenkins, that is decrypted when being retrieved via environment variable
199
+
200
+ Multiple: Override
201
+
202
+ Example:
203
+
204
+ builder.freestyle 'hello_world-deploy' do
205
+ password 'ADMIN', 'PhxHFCjgSiXR2umXhALLq+RzqJBxODDJT4t9Tw5JXbI='
206
+ end
207
+
208
+ **password_parameter**
209
+
210
+ Description: Create a parameter for password for a job
211
+
212
+ Multiple: Add
213
+
214
+ Example:
215
+
216
+ builder.freestyle 'hello_world-check' do
217
+ password_parameter 'PASS' do
218
+ default 'xyz#'
219
+ end
220
+ end
221
+
222
+ **pollscm**
223
+
224
+ Description: Specify SCM polling frequency in crontab format
225
+
226
+ Multiple: Override
227
+
228
+ Example:
229
+
230
+ builder.freestyle 'hello_world-master' do
231
+ pollscm '*/5 * * * *'
232
+ end
233
+
234
+ **postbuild**
235
+
236
+ Description: Create post build actions freestyle/flow
237
+
238
+ Multiple: Merged
239
+
240
+ Example:
241
+
242
+ builder.freestyle 'hello_world-master' do
243
+ postbuild do
244
+ end
245
+ end
246
+
247
+ **quiet_period**
248
+
249
+ Description: Wait a specified period in seconds before running freestyle/flow
250
+
251
+ Multiple: Override
252
+
253
+ Example:
254
+
255
+ builder.freestyle 'hello_world-build' do
256
+ quiet_period 5
257
+ end
258
+
259
+ **scms**
260
+
261
+ Description: Configure multiple SCM's
262
+
263
+ Multiple: Override
264
+
265
+ Example:
266
+
267
+ builder.freestyle 'hello_world-master' do
268
+ scms do
269
+ git do
270
+ end
271
+ git do
272
+ end
273
+ end
274
+ end
275
+
276
+ **timed**
277
+
278
+ Description: Specify frequency to run a build in crontab format freestyle/flow
279
+
280
+ Multiple: Override
281
+
282
+ Example:
283
+
284
+ builder.freestyle 'hello_world-master' do
285
+ timed '*/5 * * * *'
286
+ end
287
+
288
+ **timeout**
289
+
290
+ Description: Specify elastic timeout as percentage of last 3 successful builds or absolute value in minutes if they are not available
291
+
292
+ Multiple: Override
293
+
294
+ Example:
295
+
296
+ builder.freestyle 'hello_world-build' do
297
+ timeout 'elastic' do
298
+ elastic_percentage 200
299
+ elastic_default_timeout 30
300
+ end
301
+ end
302
+
303
+ **timestamps**
304
+
305
+ Description: Show time stamp for build's console log
306
+
307
+ Multiple: Override
308
+
309
+ Example:
310
+
311
+ builder.freestyle 'hello_world-build' do
312
+ timestamps
313
+ end
data/docs/flow.md ADDED
@@ -0,0 +1,18 @@
1
+ ## Create build flow style project
2
+
3
+ **dsl**
4
+
5
+ Description: Specify groovy DSL for a flow job
6
+
7
+ Multiple: Override
8
+
9
+ Example
10
+
11
+ builder.flow 'hello_world-post' do
12
+ dsl <<EOS
13
+ build("hello_worl-" + params["GERRIT_BRANCH"],
14
+ GERRIT_REFSPEC: "refs/heads/${params["GERRIT_BRANCH"]}",
15
+ GERRIT_BRANCH: params["GERRIT_BRANCH"])
16
+ EOS
17
+
18
+ end
data/docs/freestyle.md ADDED
@@ -0,0 +1,100 @@
1
+ ## Create free style project
2
+
3
+ **ant**
4
+
5
+ Description: Run ant task
6
+
7
+ Multiple: Add
8
+
9
+ Example
10
+
11
+ builder.freestyle 'hello_world-build' do
12
+ ant do
13
+ target 'clean', 'lint'
14
+ buildfile 'nightly.xml'
15
+ java_opts '-Xmx512m', '-Xms512m'
16
+ property 'skipTest' => 'false'
17
+ end
18
+ end
19
+
20
+ **batch**
21
+
22
+ Description: Run batch command
23
+
24
+ Multiple: Add
25
+
26
+ Example
27
+
28
+ builder.freestyle 'hello_world-master' do
29
+ batch 'sc.exe query'
30
+ end
31
+
32
+ **copyartifact**
33
+
34
+ Description: Copy artifact from other build
35
+
36
+ Multiple: Add
37
+
38
+ Example
39
+
40
+ builder.freestyle 'hello_world-servicetest' do
41
+ copyartifact '$ARTIFACT_JOB' do
42
+ build_number '$ARTIFACT_BUILD_NUMBER'
43
+ file 'package/**',
44
+ 'output/**'
45
+ to '$BUILD_NUMBER'
46
+ end
47
+ end
48
+
49
+ **inject_env**
50
+
51
+ Description: Create environment variable that persists in the build
52
+
53
+ Multiple: Add
54
+
55
+ Example
56
+
57
+ builder.freestyle 'hello_world-build' do
58
+ inject_env do
59
+ properties_content 'EXAMPLE=foo'
60
+ properties_file 'env.prop'
61
+ end
62
+ end
63
+
64
+ **powershell**
65
+
66
+ Description: Run Powershell command
67
+
68
+ Multiple: Add
69
+
70
+ Example
71
+
72
+ builder.freestyle 'hello_world-master' do
73
+ powershell 'Get-Service MSQL* | foreach { sc.exe stop $_.Name }'
74
+ end
75
+
76
+ **shell**
77
+
78
+ Description: Run shell command
79
+
80
+ Multiple: Add
81
+
82
+ Example
83
+
84
+ builder.freestyle 'ops-master' do
85
+ shell 'rm -rf * || true'
86
+ end
87
+
88
+ **workspace**
89
+
90
+ Description: Set custom workspace for job
91
+
92
+ Multiple: Override
93
+
94
+ Example
95
+
96
+ builder.freestyle 'ops-master' do
97
+ workspace 'ops-m'
98
+ end
99
+
100
+
data/docs/gerrit.md ADDED
@@ -0,0 +1,70 @@
1
+ ## Configure job to act on gerrit event
2
+
3
+ **change_merged**
4
+
5
+ Description: trigger the job on Gerrit change_merged event
6
+
7
+ Multiple: Override
8
+
9
+ Example
10
+
11
+ builder.flow 'hello_world-post' do
12
+ gerrit do
13
+ change_merged
14
+ project 'hello_world' do
15
+ branch 'master','release'
16
+ end
17
+ end
18
+ end
19
+
20
+ **comment_added**
21
+
22
+ Description: trigger the job on Gerrit comment_added event
23
+
24
+ Multiple: Override
25
+
26
+ Example
27
+
28
+ builder.flow 'hello_world-gate' do
29
+ gerrit do
30
+ comment_added 'Code-Review' => '2'
31
+ project 'hello_world' do
32
+ branch 'master','release'
33
+ end
34
+ end
35
+ end
36
+
37
+ **patchset_uploaded**
38
+
39
+ Description: trigger the job on Gerrit patchset_uploaded event
40
+
41
+ Multiple: Override
42
+
43
+ Example
44
+
45
+ builder.flow 'hello_world-build' do
46
+ gerrit do
47
+ patchset_uploaded
48
+ project 'hello_world' do
49
+ branch 'master','release'
50
+ end
51
+ end
52
+ end
53
+
54
+ **project**
55
+
56
+ Description: Specify a Gerrit event filter that trigger the job
57
+
58
+ Multiple: Override
59
+
60
+ Example
61
+
62
+ builder.flow 'salesforce-post' do
63
+ gerrit do
64
+ project 'poland/technicalcomponents' do
65
+ branch 'master','release'
66
+ file 'src/Salesforce/**',
67
+ 'src/Db/Salesforce/**'
68
+ end
69
+ end
70
+ end
data/docs/git.md ADDED
@@ -0,0 +1,88 @@
1
+ ## Configure Git SCM
2
+
3
+ **git**
4
+
5
+ Description: Configure Git version as SCM
6
+
7
+ Multiple: Override
8
+
9
+ Example
10
+
11
+ builder.freestyle 'hello_world-master' do
12
+ git do
13
+ url 'ssh://builduser@gerrit.acme.com:29418/hello_world'
14
+ basedir 'hello_world'
15
+ reference_repo '$HOME/hello_world.git'
16
+ branches '$GERRIT_BRANCH'
17
+ refspec '$GERRIT_REFSPEC'
18
+ choosing_strategy 'gerrit'
19
+ git_config_name 'foo'
20
+ git_config_email 'foo@acme.com'
21
+ end
22
+ end
23
+
24
+ **jgit**
25
+
26
+ Description: Configure Git version as SCM using jgit. Credentials must be created with the specified id using groovy script
27
+
28
+ Multiple: Override
29
+
30
+ Example
31
+
32
+ builder.freestyle 'hello_world-master' do
33
+ git do
34
+ url 'ssh://builduser@gerrit.acme.com:29418/hello_world'
35
+ basedir 'hello_world'
36
+ reference_repo '$HOME/hello_world.git'
37
+ branches '$GERRIT_BRANCH'
38
+ refspec '$GERRIT_REFSPEC'
39
+ choosing_strategy 'gerrit'
40
+ git_config_name 'foo'
41
+ git_config_email 'foo@acme.com'
42
+ jgit
43
+ credentials 'foo'
44
+ end
45
+ end
46
+
47
+ Example of creating credentials
48
+
49
+ import jenkins.model.*
50
+ import hudson.plugins.sshslaves.*
51
+ import com.cloudbees.plugins.credentials.*
52
+ import com.cloudbees.plugins.credentials.common.*
53
+ import com.cloudbees.plugins.credentials.domains.*
54
+ import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
55
+
56
+ domain = Domain.global()
57
+ store = Jenkins.instance.getExtensionList(
58
+ 'com.cloudbees.plugins.credentials.SystemCredentialsProvider'
59
+ )[0].getStore()
60
+
61
+ username = credentialsId = 'foo'
62
+ passphrase = description = null
63
+
64
+ privateKey = """
65
+ -----BEGIN RSA PRIVATE KEY-----
66
+ MIIEoQIBAAKCAQEAyTsKNPUc4GkfZjNlLmLpuS+wecpCQOJs7MubPoNGk5F0cK4Q
67
+ ...
68
+ -----END RSA PRIVATE KEY-----
69
+ """
70
+
71
+ credentials = new BasicSSHUserPrivateKey(
72
+ CredentialsScope.GLOBAL,
73
+ credentialsId,
74
+ username,
75
+ new BasicSSHUserPrivateKey.DirectEntryPrivateKeySource(privateKey),
76
+ passphrase,
77
+ description
78
+ )
79
+
80
+ existing = store.getCredentials(domain).find { it.id == credentialsId }
81
+ if (existing) {
82
+ println "removing ${credentialsId}"
83
+ store.removeCredentials(domain, existing)
84
+ }
85
+
86
+ println "adding ${credentialsId}"
87
+ store.addCredentials(domain, credentials)
88
+
data/docs/index.md ADDED
@@ -0,0 +1,11 @@
1
+ ## Ruby Job Builder DSL
2
+
3
+ * [Overview](overview.md)
4
+ * [Common](common.md)
5
+ * [FreeStyle](freestyle.md)
6
+ * [Flow](flow.md)
7
+ * [Multi](multi.md)
8
+ * [View](view.md)
9
+ * [Gerrit](gerrit.md)
10
+ * [Git](git.md)
11
+ * [Postbuild](postbuild.md)
data/docs/multi.md ADDED
@@ -0,0 +1,27 @@
1
+ ## Create multi job project
2
+
3
+ **phase**
4
+
5
+ Description: Run a job phase. Phases are executed sequentially, however jobs within a phase run in parallel.
6
+
7
+ Multiple: Add
8
+
9
+ Example
10
+
11
+ builder.multi 'hello_world-deploy' do
12
+ phase 'hello_world-db-deploy' do
13
+ job 'foo-db'
14
+
15
+ job 'bar-db' do
16
+ ignore_result true
17
+ end
18
+ end
19
+
20
+ phase 'hello_world-service-deploy' do
21
+ job 'foo-service' do
22
+ retries 1
23
+ abort_others false
24
+ end
25
+ job 'bar-service'
26
+ end
27
+ end