forked from TritonDataCenter/smartos-live
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
353 lines (347 loc) · 14.8 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/*
* Copyright 2022 Joyent, Inc.
* Copyright 2022 MNX Cloud, Inc.
*/
@Library('[email protected]') _
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '30'))
timestamps()
parallelsAlwaysFailFast()
}
// Don't assign a specific agent for the entire job, in order to better
// share resources across jobs. Otherwise, we'd tie up an agent here for
// the duration of all stages for a given build, despite it not doing any
// actual work.
agent none
parameters {
string(
name: 'PLAT_CONFIGURE_ARGS',
defaultValue: '',
description:
'Arguments to smartos-live\'s configure script.\n' +
'By setting any of these, we only run the <b>"default"</b>\n' +
'Jenkins pipeline stage using the user-supplied value.<br/>' +
'<dl>\n' +
'<dt>-c</dt>\n' +
'<dd>clobber Illumos before each build [default: no]</dd>\n' +
'<dt>-d</dt>\n' +
'<dd>build Illumos in DEBUG mode only [default: no]</dd>\n' +
'<dt>-h</dt>\n' +
'<dd>this message</dd>\n' +
'<dt>-p gcc10</dt>\n' +
'<dd>primary compiler version [default: gcc7]</dd>\n' +
'<dt>-P password</dt>\n' +
'<dd>platform root password [default: randomly chosen]</dd>\n' +
'<dt>-S</dt>\n' +
'<dd>do *not* run smatch [default is to run smatch]</dd>\n' +
'<dt>-s gcc10</dt>\n' +
'<dd>shadow compilers, comma delimited (gcc10,gcc#) [default: none]</dd>\n' +
'</dl>'
)
text(
name: 'CONFIGURE_PROJECTS',
defaultValue:
'illumos-extra: master: origin\n' +
'illumos: master: origin\n' +
'local/kbmd: master: origin\n' +
'local/kvm-cmd: master: origin\n' +
'local/kvm: master: origin\n' +
'local/mdata-client: master: origin\n' +
'local/ur-agent: master: origin',
description:
'This parameter is used by smartos-live to decide ' +
'which branches to checkout and configure.</br>\n' +
'The string is formatted:<br/>' +
'<pre>\n' +
'<relative path to ./projects>:<branch name>:[optional git URL]\n' +
'</pre>' +
'In place of a full git url, the keyword \'origin\' ' +
'is allowed in order to specify the default github remote URL.'
)
// The default choice() is the first list item
choice(
name: 'PLATFORM_BUILD_FLAVOR',
choices: ['triton', 'smartos', 'triton-and-smartos'],
description:
'<p><dl>\n' +
'<dt>triton</dt>' +
'<dd>the default, build a platform image and publish it</dd>\n' +
'<dt>smartos</dt>' +
'<dd>build a platform image and smartos artifacts, but do ' +
'not publish a Triton platform image</dd>\n' +
'<dt>triton-and-smartos</dt>' +
'<dd>build both of the above</dd>\n' +
'</dl>' +
'The following are the SmartOS artifacts that will be ' +
'published when selecting one of the smartos options: ' +
'<ul>\n' +
' <li>SmartOS iso image</li>\n' +
' <li>SmartOS usb image</li>\n' +
' <li>SmartOS vmware image</li>\n' +
' <li>SmartOS Changelog file</li>\n' +
'</ul></p>'
)
booleanParam(
name: 'BUILD_STRAP_CACHE',
defaultValue: false,
description: 'This parameter declares whether to build and ' +
'upload a new strap-cache as part of this build. This ' +
'should only be true when triggered by a push to illumos-extra.'
)
booleanParam(
name: 'ONLY_BUILD_STRAP_CACHE',
defaultValue: false,
description: '<p>This parameter declares that this build should ' +
'<b>only</b> build and upload the strap cache tarball. This ' +
'is useful in cases where a push to illumos-extra coincides ' +
'with an otherwise broken platform build.</p>'
)
}
stages {
stage('check') {
agent {
node {
label 'platform:true && image_ver:21.4.0 && pkgsrc_arch:x86_64 && ' +
'dram:16gb && !virt:kvm && fs:pcfs && fs:ufs && jenkins_agent:3'
customWorkspace "workspace/smartos-${BRANCH_NAME}-check"
}
}
steps{
sh('''
set -o errexit
set -o pipefail
./tools/build_jenkins -c -F check
''')
}
post {
// We don't notify here, as that doesn't add much
// value. The checks should always pass, and it's unlikely
// that developers will care when they do. If they don't
// pass, then the (likely) GitHub PR will be updated with a
// failure status, and the developer can then investigate.
// https://jenkins.io/doc/pipeline/steps/ws-cleanup/
// We don't clean on build failure so that there's a chance to
// investigate the breakage. Hopefully, a subsequent successful
// build will then clean up the workspace, though that's not
// guaranteed for abandoned branches.
always {
cleanWs cleanWhenSuccess: true,
cleanWhenFailure: false,
cleanWhenAborted: true,
cleanWhenNotBuilt: true,
deleteDirs: true
}
}
}
stage('build-variants') {
parallel {
stage('default') {
agent {
// There seems to be a Jenkins bug where ${WORKSPACE} isn't
// resolved at the time of node declaration, so we can't reuse
// that when setting our custom workspace for each separate
// pipeline stage (to allow users the chance of inspecting
// workspaces from different pipeline stages after the build
// completes).
// Use ${BRANCH_NAME} instead.
node {
label 'platform:true && image_ver:21.4.0 && pkgsrc_arch:x86_64 && ' +
'dram:16gb && !virt:kvm && fs:pcfs && fs:ufs && jenkins_agent:3'
customWorkspace "workspace/smartos-${BRANCH_NAME}-default"
}
}
when {
// We only want to trigger most pipeline stages on either a
// push to master, or an explicit build request from a user.
// Otherwise, every push to a PR branch would cause a build,
// which might be excessive. The exception is the 'check' stage
// above, which is ~ a 2 minute build.
beforeAgent true
allOf {
anyOf {
branch 'master'
triggeredBy cause: 'UserIdCause'
}
environment name: 'ONLY_BUILD_STRAP_CACHE', value: 'false'
}
}
steps {
sh('git clean -fdx')
sh('''
set -o errexit
set -o pipefail
export ENGBLD_BITS_UPLOAD_IMGAPI=true
./tools/build_jenkins -c -S default
''')
}
post {
always {
archiveArtifacts artifacts: 'output/default/**',
onlyIfSuccessful: false,
allowEmptyArchive: true
cleanWs cleanWhenSuccess: true,
cleanWhenFailure: false,
cleanWhenAborted: true,
cleanWhenNotBuilt: true,
deleteDirs: true
joySlackNotifications(
channel: 'smartos', comment: 'default')
}
}
}
stage('debug') {
agent {
node {
label 'platform:true && image_ver:21.4.0 && pkgsrc_arch:x86_64 && ' +
'dram:16gb && !virt:kvm && fs:pcfs && fs:ufs && jenkins_agent:3'
customWorkspace "workspace/smartos-${BRANCH_NAME}-debug"
}
}
when {
beforeAgent true
allOf {
anyOf {
branch 'master'
triggeredBy cause: 'UserIdCause'
}
// If a user has set PLAT_CONFIGURE_ARGS, that
// suggests we may have been asked for a special debug, or
// gcc, etc. build. In that case, don't bother building
// any stages which may duplicate the arguments they
// specified. The same goes for the rest of the pipeline
// stages.
environment name: 'PLAT_CONFIGURE_ARGS', value: ''
environment name: 'ONLY_BUILD_STRAP_CACHE', value: 'false'
}
}
steps {
sh('git clean -fdx')
sh('''
set -o errexit
set -o pipefail
export PLAT_CONFIGURE_ARGS="-d $PLAT_CONFIGURE_ARGS"
./tools/build_jenkins -c -d -S debug
''')
}
post {
always {
archiveArtifacts artifacts: 'output/debug/**',
onlyIfSuccessful: false,
allowEmptyArchive: true
cleanWs cleanWhenSuccess: true,
cleanWhenFailure: false,
cleanWhenAborted: true,
cleanWhenNotBuilt: true,
deleteDirs: true
joySlackNotifications(
channel: 'smartos', comment: 'debug')
}
}
}
stage('gcc10') {
agent {
node {
label 'platform:true && image_ver:21.4.0 && pkgsrc_arch:x86_64 && ' +
'dram:16gb && !virt:kvm && fs:pcfs && fs:ufs && jenkins_agent:3'
customWorkspace "workspace/smartos-${BRANCH_NAME}-gcc10"
}
}
when {
beforeAgent true
allOf {
anyOf {
branch 'master'
triggeredBy cause: 'UserIdCause'
}
environment name: 'PLAT_CONFIGURE_ARGS', value: ''
environment name: 'ONLY_BUILD_STRAP_CACHE', value: 'false'
}
}
steps {
sh('git clean -fdx')
sh('''
export PLAT_CONFIGURE_ARGS="-p gcc10 -r $PLAT_CONFIGURE_ARGS"
# enough to make sure we don't pollute the main Manta dir
# Also for now we implicitly promise that the gcc10 deliverables are DEBUG,
# but we could choose to make -gcc10 *and* -debug-gcc10 stages later and alter
# PLATFORM_DEBUG_SUFFIX accordingly.
export PLATFORM_DEBUG_SUFFIX=-gcc10
./tools/build_jenkins -c -d -S gcc10
''')
}
post {
always {
archiveArtifacts artifacts: 'output/gcc10/**',
onlyIfSuccessful: false,
allowEmptyArchive: true
cleanWs cleanWhenSuccess: true,
cleanWhenFailure: false,
cleanWhenAborted: true,
cleanWhenNotBuilt: true,
deleteDirs: true
joySlackNotifications(
channel: 'smartos', comment: 'gcc10')
}
}
}
stage('strap-cache') {
agent {
node {
label 'platform:true && image_ver:21.4.0 && pkgsrc_arch:x86_64 && ' +
'dram:16gb && !virt:kvm && fs:pcfs && fs:ufs && jenkins_agent:3'
customWorkspace "workspace/smartos-${BRANCH_NAME}-strap-cache"
}
}
when {
beforeAgent true
// We only build strap-cache as a result of a push to
// illumos-extra. See the Jenkinsfile in that repository
// which has a build(..) step for smartos-live that sets
// this environment value.
anyOf {
environment name: 'BUILD_STRAP_CACHE', value: 'true'
environment name: 'ONLY_BUILD_STRAP_CACHE', value: 'true'
}
}
steps {
sh('git clean -fdx')
sh('''
set -o errexit
set -o pipefail
export MANTA_TOOLS_PATH=/root/bin/
./tools/build_jenkins -c -F strap-cache -S strap-cache
''')
}
post {
always {
archiveArtifacts artifacts: 'output/strap-cache/**',
onlyIfSuccessful: false,
allowEmptyArchive: true
cleanWs cleanWhenSuccess: true,
cleanWhenFailure: false,
cleanWhenAborted: true,
cleanWhenNotBuilt: true,
deleteDirs: true
joySlackNotifications(
channel: 'smartos', comment: 'strap-cache')
}
}
}
}
}
}
post {
always {
joySlackNotifications(
channel: 'jenkins', comment: 'pipeline complete')
joySlackNotifications(
channel: 'smartos', comment: 'pipeline complete')
}
}
}