-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile.cycle
575 lines (527 loc) · 21.2 KB
/
Jenkinsfile.cycle
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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
#!/usr/bin/env groovy
conda_packages = [
"ataos",
"atbuilding",
"atdome",
"atdometrajectory",
"athexapod",
"atmcs_sim",
"atmonochromator",
"atpneumatics_sim",
"atspectrograph",
"atwhitelight",
"audio_broadcaster",
"authorize",
"cbp",
"dimm",
"dream",
"dmocps",
"dsm",
"eas",
"electrometer",
"epm",
"ess",
"fiberspectrograph",
"genericcamera",
"gis",
"headerservice",
"hvac",
"integrationtests",
"lasertracker",
"ledprojector",
"linearstage",
"love-commander",
"love-csc",
"love-frontend",
"love-frontend-k8s",
"love-manager",
"love-manager-static",
"love-producer",
"love-view-backup",
"mtaircompressor",
"mthexapod",
"mtdome",
"mtdometrajectory",
"mtm2",
"mtmount",
"mtrotator",
"nightreport",
"ospl-daemon",
"pmd",
"salkafka",
"scheduler",
"schedview",
"test",
"tunablelaser",
"watcher",
"weatherforecast"
]
pipeline {
options {
buildDiscarder(
logRotator(
artifactDaysToKeepStr: '',
artifactNumToKeepStr: '',
daysToKeepStr: '14',
numToKeepStr: '10'
))
disableConcurrentBuilds()
}
agent {
label "${params.build_agent}"
}
environment {
registryCredential = "dockerhub-lssttsadmin"
pub_registryCredential = "dockerhub-lssttsadmin"
CONDA_PACKAGES = conda_packages.join(" ")
CONDA_PACKAGES_C = conda_packages.join("_c ").concat("_c")
CAMSPEC_GENCAM = "genericcamera-canon genericcamera-vimba"
CAMSPEC_GENCAM_C = "genericcamera-canon_c genericcamera-vimba_c"
}
parameters {
booleanParam(
defaultValue: false,
description: "Set the CACHE_OPTION variable to '--no-cache'",
name: 'set_cache_option'
)
choice choices: ['Node3_4CPU', 'CSC_Conda_Node', 'Node1_4CPU', 'Node2_8CPU'], description: 'Select the build agent', name: 'build_agent'
booleanParam defaultValue: false, description: "Build/push Conda Package Builder arm64 and aarch64 images.", name: 'build_conda_package_builder'
booleanParam defaultValue: false, description: "Build/push base deployment image (only run this if you are building revision 0).", name: 'deploy_conda'
booleanParam defaultValue: false, description: "Build/push lsstsqre deployment image (only run this if you are building revision 0 or updating the DM stack version).", name: 'deploy_lsstsqre'
booleanParam defaultValue: false, description: "Build/push ts-cycle conda package.", name: 'ts_cycle'
booleanParam defaultValue: false, description: "Build/push all components based on base deployment image.", name: 'base_components'
choice(name: 'component', choices: ["ALL"] + conda_packages, description: "Select one component to build. Building all components is only allowed when building revision 0.")
booleanParam defaultValue: false, description: "Build/push ESS Controller image.", name: 'build_ess_controller'
booleanParam defaultValue: false, description: "Build/push Vents Controller image.", name: 'build_vents_controller'
booleanParam defaultValue: false, description: "Build/push AudioTrigger Controller image.", name: 'build_audiotrigger_controller'
booleanParam defaultValue: false, description: "Build/push camera-specific GenericCamera images.", name: 'build_camspec_gencam'
booleanParam defaultValue: false, description: "Build/push M1M3 simulator image.", name: 'build_m1m3_sim'
booleanParam defaultValue: false, description: "Build/push pointing component deployment image.", name: 'build_ptg'
booleanParam defaultValue: false, description: "Build/push MTAOS image.", name: 'build_mtaos'
booleanParam defaultValue: false, description: "Build/push OODS image.", name: 'build_oods'
booleanParam defaultValue: false, description: "Build/push scriptqueue image.", name: 'build_scriptqueue'
booleanParam defaultValue: false, description: "Build/push sal-sciplat recommended image? This adds Telescope and Site layer to a lsstsqre/centos image in prepartion for building nublado images.", name: 'build_sciplat'
booleanParam defaultValue: false, description: "Build/push sal-sciplat-lab recommended image? Adds SQuaRe layer to sal-sciplat to produce a nublado-ready image.", name: 'build_sciplat_lab_recommended'
booleanParam defaultValue: false, description: "Build/push RubinTV Rapid Analysis.", name: 'rapid_analysis'
booleanParam defaultValue: false, description: "Build/push development image.", name: 'develop_env'
}
stages {
stage ('Build Conda Package Builder images') {
when {
expression { params.build_conda_package_builder }
}
steps {
build job: "CondaPackageBuilder_amd64/" + env.BRANCH_NAME.replace("/", "%2F"), parameters: [booleanParam(name: 'build_conda_package_builder', value: true)], wait: false
build job: "CondaPackageBuilder_aarch64/" + env.BRANCH_NAME.replace("/", "%2F"), parameters: [booleanParam(name: 'build_conda_package_builder_aarch64', value: true)], wait: false
}
}
stage ('Build deploy-conda-private') {
when {
expression { params.deploy_conda }
}
steps {
withEnv(["HOME=${env.WORKSPACE}"]) {
sh """
export \$(cat cycle/cycle.env | grep rev | sed 's/#.*//g' | xargs)
export \$(cat cycle/cycle.env | grep CYCLE | sed 's/#.*//g' | xargs)
if [ "\$rev" != ".000" ]; then echo "FAILED: base conda image can only be built when building revision 0."; exit 1; else echo "BUILDING CYCLE \${CYCLE}\${rev}";fi
"""
}
withCredentials([file(credentialsId: 'yum-nexus-private', variable: 'yum_nexus_private')]) {
sh "cp \$yum_nexus_private ${env.WORKSPACE}/build/common/"
}
// When using the docker container, we need to change
// the HOME path to WORKSPACE to have the authority
// to install the packages.
script{
def cacheOption = params.set_cache_option ? "--no-cache" : ""
withEnv(["HOME=${env.WORKSPACE}"]) {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build ${cacheOption} deploy-conda-private
"""
}
}
script {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml push deploy-conda-private
"""
}
}
}
}
stage ('Build deploy-lsstsqre-private') {
when {
expression { params.deploy_lsstsqre }
}
steps {
withCredentials([file(credentialsId: 'yum-nexus-private', variable: 'yum_nexus_private')]) {
sh "cp \$yum_nexus_private ${env.WORKSPACE}/build/common/"
}
script{
def cacheOption = params.set_cache_option ? "--no-cache" : ""
withEnv(["HOME=${env.WORKSPACE}"]) {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build ${cacheOption} deploy-lsstsqre-private
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build deploy-lsstsqre-private_c
"""
}
}
script {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml push deploy-lsstsqre-private deploy-lsstsqre-private_c
"""
}
}
}
}
stage ('Build ts-cycle conda package') {
when {
expression { params.ts_cycle }
}
steps {
build job: "Cycle_conda_package/" + env.BRANCH_NAME.replace("/", "%2F"), wait: false
}
}
stage ('Build ALL base components') {
when {
allOf {
expression { params.base_components }
expression { params.component.equals("ALL")}
}
}
steps {
withEnv(["HOME=${env.WORKSPACE}"]) {
sh """
export \$(cat cycle/cycle.env | grep rev | sed 's/#.*//g' | xargs)
export \$(cat cycle/cycle.env | grep CYCLE | sed 's/#.*//g' | xargs)
if [ "\$rev" != ".000" ]; then echo "FAILED: Building ALL components only allowed when building revision 0."; exit 1 ; else echo "BUILDING CYCLE \${CYCLE}\${rev}";fi
"""
}
script{
def cacheOption = params.set_cache_option ? "--no-cache" : ""
withEnv(["HOME=${env.WORKSPACE}"]) {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh """
export DOCKER_BUILDKIT=0
for comp in \${CONDA_PACKAGES}; do
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build ${cacheOption} \${comp}
done
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build \${CONDA_PACKAGES_C}
"""
}
}
}
script {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml push \${CONDA_PACKAGES} \${CONDA_PACKAGES_C}
"""
}
}
}
}
stage ('Build single base component') {
when {
allOf {
expression { params.base_components }
not{ expression { params.component.equals("ALL") } }
}
}
steps {
script{
def cacheOption = params.set_cache_option ? "--no-cache" : ""
withEnv(["HOME=${env.WORKSPACE}"]) {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build ${cacheOption} ${params.component}
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build ${cacheOption} ${params.component}_c
"""
}
}
}
script {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml push ${params.component} ${params.component}_c
"""
}
}
}
}
stage ('Build ESS Controller Docker image') {
when {
expression { params.build_ess_controller }
}
steps {
build job: "EssController/" + env.BRANCH_NAME.replace("/", "%2F"), parameters: [booleanParam(name: 'build_ess_controller', value: true)], wait: false
}
}
stage ('Build Vents Controller Docker image') {
when {
expression { params.build_vents_controller }
}
steps {
build job: "VentsController/" + env.BRANCH_NAME.replace("/", "%2F"), parameters: [booleanParam(name: 'build_vents_controller', value: true)], wait: false
}
}
stage ('Build AudioTrigger Controller Docker image') {
when {
expression { params.build_audiotrigger_controller }
}
steps {
build job: "AudioTriggerController/" + env.BRANCH_NAME.replace("/", "%2F"), parameters: [booleanParam(name: 'build_audiotrigger_controller', value: true)], wait: false
}
}
stage ('Build camera specific GenericCamera Docker images') {
when {
expression { params.build_camspec_gencam }
}
steps {
withCredentials([file(credentialsId: 'nexus-netrc', variable: 'nexus_netrc')]) {
sh "cp \$nexus_netrc ${env.WORKSPACE}/build/common/"
}
script{
def cacheOption = params.set_cache_option ? "--no-cache" : ""
withEnv(["HOME=${env.WORKSPACE}"]) {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build ${cacheOption} \${CAMSPEC_GENCAM}
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build \${CAMSPEC_GENCAM_C}
"""
}
}
}
script {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml push \${CAMSPEC_GENCAM} \${CAMSPEC_GENCAM_C}
"""
}
}
}
}
stage ('Build M1M3 simulator') {
when {
expression { params.build_m1m3_sim }
}
steps {
script{
def cacheOption = params.set_cache_option ? "--no-cache" : ""
withEnv(["HOME=${env.WORKSPACE}"]) {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build ${cacheOption} mtm1m3_sim
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build mtm1m3_sim_c
"""
}
}
}
script {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml push mtm1m3_sim mtm1m3_sim_c
"""
}
}
}
}
stage ('Build PTG') {
when {
expression { params.build_ptg }
}
steps {
script{
// Create a variable based on user input
def cacheOption = params.set_cache_option ? "--no-cache" : ""
withCredentials([sshUserPrivateKey(credentialsId: 'RubinObsWorkerSSHKey', keyFileVariable: 'github_cred')]) {
sh "cp \$github_cred ${env.WORKSPACE}/build/ptg/id_rsa"
}
withEnv(["HOME=${env.WORKSPACE}"]) {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build ${cacheOption} ptg ptg_c
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build ptg_c
"""
}
}
}
script {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml push ptg ptg_c
"""
}
}
}
}
stage ('Build mtaos') {
when {
expression { params.build_mtaos }
}
steps {
script{
def cacheOption = params.set_cache_option ? "--no-cache" : ""
withEnv(["HOME=${env.WORKSPACE}"]) {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh """
export DOCKER_BUILDKIT=0
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build ${cacheOption} mtaos
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build mtaos_c
"""
}
}
}
script {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml push mtaos mtaos_c
"""
}
}
}
}
stage ('Build oods') {
when {
expression { params.build_oods }
}
steps {
script {
withEnv(["HOME=${env.WORKSPACE}"]) {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh"""
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build oods oods_c
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build atoods atoods_c ccoods ccoods_c mtoods mtoods_c
"""
}
}
}
script {
withEnv(["HOME=${env.WORKSPACE}"]) {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh"""
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml push oods oods_c atoods atoods_c ccoods ccoods_c mtoods mtoods_c
"""
}
}
}
}
}
stage ('Build scriptqueue') {
when {
expression { params.build_scriptqueue }
}
steps {
script{
def cacheOption = params.set_cache_option ? "--no-cache" : ""
withEnv(["HOME=${env.WORKSPACE}"]) {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build ${cacheOption} scriptqueue
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build scriptqueue_c
"""
}
}
}
script {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml push scriptqueue scriptqueue_c
"""
}
}
}
}
stage ('Build Sal Sciplat (pre-nublado) recommended image') {
when {
expression { params.build_sciplat }
}
steps {
withCredentials([file(credentialsId: 'yum-nexus-private', variable: 'yum_nexus_private')]) {
sh "cp \$yum_nexus_private ${env.WORKSPACE}/build/common/"
}
script{
def cacheOption = params.set_cache_option ? "--no-cache" : ""
withEnv(["HOME=${env.WORKSPACE}"]) {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build ${cacheOption} opensplice-lsstsqre-licensed
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build ${cacheOption} sal-sciplat-licensed
"""
}
}
script {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml push sal-sciplat-licensed
"""
}
}
}
}
stage ('Build Sal Sciplat Lab (nublado) recommended image') {
when {
expression { params.build_sciplat_lab_recommended }
}
steps {
build job: "SalSciplatLab/" + env.BRANCH_NAME.replace("/", "%2F"), parameters: [booleanParam(name: 'build_sciplat_lab_recommended', value: true)], wait: false
}
}
stage ('Build RubinTV Rapid Analysis') {
when {
expression { params.rapid_analysis }
}
steps {
script{
def cacheOption = params.set_cache_option ? "--no-cache" : ""
withEnv(["HOME=${env.WORKSPACE}"]) {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build ${cacheOption} rapid-analysis
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build rapid-analysis_c
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build ${cacheOption} rapid-analysis-usdf
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build rapid-analysis-usdf_c
"""
}
}
script {
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml push rapid-analysis rapid-analysis_c
"""
}
}
script {
docker.withRegistry("", pub_registryCredential) {
sh """
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml push rapid-analysis-usdf rapid-analysis-usdf_c
"""
}
}
}
}
stage ('Build development image') {
when {
expression { params.develop_env }
}
steps {
withCredentials([file(credentialsId: 'yum-nexus-private', variable: 'yum_nexus_private')]) {
sh "cp \$yum_nexus_private ${env.WORKSPACE}/build/common/"
}
script {
def cacheOption = params.set_cache_option ? "--no-cache" : ""
docker.withRegistry("https://ts-dockerhub.lsst.org/", "nexus3-lsst_jenkins") {
sh """
export DOCKER_BUILDKIT=0
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build ${cacheOption} --pull base-sqre-private
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml push base-sqre-private
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build ${cacheOption} --pull salobj-private
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml push salobj-private
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml build ${cacheOption} --pull develop-env-private
docker compose --env-file cycle/cycle.env -f cycle/docker-compose.yaml push develop-env-private
"""
}
}
}
}
}
}