forked from adoptium/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
662 lines (612 loc) · 24.6 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
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
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
/*
--------------------------------------------
buildArch RPM DEB Comments
--------------------------------------------
x86_64 x86_64 amd64
armv7l armv7hl armhf arm32
aarch64 aarch64 arm64 arm64
ppc64le ppc64le ppc64le
source src - only for SRPM and no need specify as option or target
s390x s390x s390x only for jdk8+
riscv64 riscv64 riscv64 only for JDK21+
*/
env.NODE_LABEL = 'dockerBuild&&linux&&x64' // Default node and also used for build RedHat + Suse + Debian x64
env.PRODUCT = 'temurin'
class Types {
final static String JDK = 'Jdk'
final static String JRE = 'Jre'
final static List<String> ALL = [JDK, JRE]
static String displayName(TYPE, VERSION, ARCH, DISTRO) {
return "${TYPE.toLowerCase()}${VERSION} - ${ARCH} - ${DISTRO}"
}
}
pipeline {
agent {
label NODE_LABEL
}
tools {
jfrog 'jfrog-cli'
}
options {
timeout(time: 2, unit: 'HOURS')
}
parameters {
choice(name: 'TYPE', choices: Types.ALL, description: 'Build JDK or JRE')
choice(name: 'VERSION', choices: ['8', '11', '17', '21', '22'], description: 'Build for specific JDK VERSION')
choice(name: 'ARCH', choices: ['x86_64', 'armv7hl', 'armv7l', 'aarch64', 'ppc64le', 's390x', 'riscv64', 'all'], description: 'Build for specific platform\n s390x not for VERSION 8\n Use armv7l for DebARM32 armv7hl for RH/Suse')
choice(name: 'DISTRO', choices: ['all', 'Alpine', 'Debian', 'RedHat', 'Suse'], description: 'Build for specific Distro\n Select RPM builds for RedHat and Suse')
booleanParam(name: 'uploadPackage', defaultValue: false, description: 'Tick this box to upload the deb/rpm files (exclude src.rpm) to Artifactory for official release')
booleanParam(name: 'uploadSRCRPM', defaultValue: false, description: 'Tick this box to upload (src.rpm files) to Artifactory')
string(name: 'gitrepo', defaultValue: getCurrentRepoUrl(), description: 'Do not modify unless want to build from a specific gitrepo')
string(name: 'gitbranch', defaultValue: getCurrentBranch(), description: 'Do not change unless want to build on a specific branch from above gitrepo')
booleanParam(name: 'enableGpgSigning', defaultValue: true, description: 'Require GPG Signing')
booleanParam(name: 'enableDebug', defaultValue: false, description: 'Tick to enable --stacktrace for gradle build')
}
stages {
stage('Prepare Build') {
steps {
script {
currentBuild.displayName = Types.displayName(TYPE, VERSION, ARCH, DISTRO)
currentBuild.description = env.BUILD_USER_ID
sh('docker --version')
}
checkout(
[
$class: 'GitSCM',
branches: [[name: "$gitbranch"]],
extensions: [[$class: 'CleanBeforeCheckout', deleteUntrackedNestedRepositories: true]],
userRemoteConfigs: [[url: "$gitrepo"]]
]
)
dir('linux') {
stash name: 'installercode', includes: '**'
}
}
}
stage('BUILD') {
parallel{
stage('Build Installer for Alpine') {
when {
beforeAgent true
anyOf {
expression { params.DISTRO == 'all' }
expression { params.DISTRO == 'Alpine' } // only trigger debian build
}
}
steps{
dir('linuxDebian') {
script {
jenkinsStepAlpine()
}
}
}
}
stage('Build Installer for Debian') {
when {
beforeAgent true
anyOf {
expression { params.DISTRO == 'all' }
expression { params.DISTRO == 'Debian' } // only trigger debian build
}
}
// specific jenkins agent will be assigned inside of jenkinsSepDeb() per ARCH
steps {
dir('linuxDebian') {
script {
jenkinsStepDeb()
}
}
}
}
stage('Build Installer for Redhat') {
when {
beforeAgent true
anyOf {
expression { params.DISTRO == 'all' }
expression { params.DISTRO == 'RedHat' } // only trigger redhat build
}
}
steps {
dir('linuxRedHat') {
script {
DISTRO = 'RedHat'
jenkinsStepNonDeb('RedHat')
}
}
}
}
stage('Build Installer for Suse') {
when {
beforeAgent true // do condition when before allocate to agent
anyOf {
expression { params.DISTRO == 'all' }
expression { params.DISTRO == 'Suse' } // only trigger suse build
}
}
steps {
dir('linuxSuse') {
script {
DISTRO = 'Suse'
jenkinsStepNonDeb('Suse')
}
}
}
}
}
}
}
}
/*
* Common Functions
*/
// This makes it easier to run the builds from a different repository (for testing purposes) by default
private String getCurrentRepoUrl() {
return scm.getUserRemoteConfigs().first().getUrl() ?: 'https://github.com/adoptium/installer'
}
private String getCurrentBranch() {
return scm.branches.first().name ?: 'master'
}
// Define Generic Test & Upload Function
def CheckAndUpload(String Target, String Distro, String BuildArch, String Version, String DistroList, String Value, String PackageDir, String Key, String FileName) {
echo "Entering Check & Upload"
// Set Env Vars For Debs & Rpms
env.BUILDARCH = BuildArch
env.VERSION = Version
env.DISTROLIST = DistroList
env.VALUE = Value
env.PACKAGEDIR = PackageDir
env.KEY = Key
env.FILENAME = FileName
try {
def ResponseCode = sh(script: "curl -o /dev/null --silent --head --write-out '%{http_code}' ${Target}", returnStdout: true).trim()
echo "ResponseCode = ${ResponseCode}"
if ( ResponseCode == '200') {
echo "Target Exists - Skipping"
} else {
echo "Target Doesnt Exist - Upload Files"
switch(Distro) {
case "Debian":
// Not RISC Use JF CLI
if (BuildArch != "riscv64") {
jf 'rt u **/build/ospackage/temurin-*${BUILDARCH}.deb deb/pool/main/t/temurin-${VERSION}/ --target-props=${DISTROLIST}deb.component=main;deb.architecture=${BUILDARCH} --flat=true'
}
if (BuildArch == "riscv64") {
handleRISCVUpload("Debian", "${BUILDARCH}", "${VERSION}", "${DISTROLIST}", "", "", "")
}
break
case "Alpine":
jf 'rt u **/build/ospackage/${FILENAME} apk/alpine/main/${BUILDARCH}/ --flat=true'
break
case "RPMS":
if (BuildArch != "riscv64") {
jf 'rt u **/build/ospackage/*.${VALUE}.rpm ${PACKAGEDIR}/${KEY}/Packages/ --flat=true'
}
if (BuildArch == "riscv64") {
handleRISCVUpload("RPMS","" ,"", "", "${VALUE}", "${PACKAGEDIR}", "${KEY}" )
}
break
default:
echo "Default Case"
if (BuildArch != "riscv64") {
jf 'rt u **/build/ospackage/*.${VALUE}.rpm ${PACKAGEDIR}/${KEY}/Packages/ --flat=true'
}
if (BuildArch == "riscv64") {
handleRISCVUpload("RPMS","" ,"", "", "${VALUE}", "${PACKAGEDIR}", "${KEY}" )
}
break
}
}
} catch (Exception e) {
error "Error While Checking URL ${Target}: ${e.message}"
}
}
// RISC-V Upload Function
def handleRISCVUpload(String Distro, String BuildArch, String Version, String DistroList, String Value, String PackageDir, String Key ) {
node("dockerBuild&&linux&&x64") {
tool name: 'jfrog-cli', type: 'jfrog'
env.DISTRO = Distro
env.BUILDARCH = BuildArch
env.VERSION = Version
env.DISTROLIST = DistroList
env.VALUE = Value
env.PACKAGEDIR = PackageDir
env.KEY = Key
def copiedFiles = copyArtifacts(filter: '**/build/ospackage/*,**/build/reports/**,**/packageTest/dependencies/deb/*', projectName: env.JOB_NAME, selector: specific(env.BUILD_NUMBER))
switch(Distro) {
case "Debian":
echo "Debian Upload"
jf 'rt u **/build/ospackage/temurin-*${BUILDARCH}.deb deb/pool/main/t/temurin-${VERSION}/ --target-props=${DISTROLIST}deb.component=main;deb.architecture=${BUILDARCH} --flat=true'
break
case "RPMS":
echo "RPM Upload"
jf 'rt u **/build/ospackage/*.${VALUE}.rpm ${PACKAGEDIR}/${KEY}/Packages/ --flat=true'
break
default:
echo "Default Upload"
jf 'rt u **/build/ospackage/*.${VALUE}.rpm ${PACKAGEDIR}/${KEY}/Packages/ --flat=true'
break
}
// Remove copied artifacts
for (copiedFile in copiedFiles) {
fileToDelete = copiedFile.filePath
echo "Deleting file: ${fileToDelete}"
deleteDir(path: fileToDelete)
}
}
}
// function only handle debian as DISTRO
def jenkinsStepDeb() {
def temurinVersion = "${TYPE.toLowerCase()} ${VERSION} - ${ARCH}"
def VERSION = "${VERSION}"
echo "Installer Job for Temurin ${temurinVersion} - Debian"
//make sure this is an array not a string
def debArchAllList = []
// for one single ARCH add into array
debArchAllList.add("${ARCH}")
// when ARCH = all, rewrite list
if ("${ARCH}" == 'all') {
debArchAllList = ['x86_64', 'armv7l', 'aarch64', 'ppc64le', 's390x', 'riscv64']
}
// remove s390x for JDK8
if ("${VERSION}" == '8' && "${ARCH}" == 'all') {
debArchAllList = ['x86_64', 'armv7l', 'aarch64', 'ppc64le']
}
// remove riscv64 for JDK11
if ("${VERSION}" == '11' && "${ARCH}" == 'all') {
debArchAllList = ['x86_64', 'armv7l', 'aarch64', 'ppc64le', 's390x']
}
// remove riscv64 for JDK17
if ("${VERSION}" == '17' && "${ARCH}" == 'all') {
debArchAllList = ['x86_64', 'armv7l', 'aarch64', 'ppc64le', 's390x']
}
// remove Arm32 & add riscv64 for JDK21
if ("${VERSION}" == '21' && "${ARCH}" == 'all' ) {
debArchAllList = ['x86_64', 'aarch64', 'ppc64le', 's390x', 'riscv64']
}
// remove Arm32 & add riscv64 for JDK22
if ("${VERSION}" == '22' && "${ARCH}" == 'all') {
debArchAllList = ['x86_64', 'aarch64', 'ppc64le', 's390x', 'riscv64']
}
debArchAllList.each { DebARCH ->
// special handle: no label x86_64 only x64 for debian agent
def debLabel = "${DebARCH}&&docker"
if ("${DebARCH}" == 'x86_64') {
debLabel = 'x64&&dockerBuild'
}
// special handle: force arm32 on arm 64 dockerhost
if ("${DebARCH}" == 'armv7l') {
debLabel = 'armv8&&build&&dockerBuild&&dockerhost'
}
if ("${DebARCH}" == 'riscv64') {
debLabel = 'riscv64&&dockerInstaller'
}
// reallocate jenkins agent per element in list
node("linux&&${debLabel}") {
setup('Debian', "${DebARCH}")
if ("${DebARCH}" != 'riscv64') {
tool name: 'jfrog-cli', type: 'jfrog'
}
unstash 'installercode'
buildAndTest('Debian', "${DebARCH}","${VERSION}")
if (params.uploadPackage.toBoolean()) {
echo "Upload artifacts for ${VERSION} - ${DebARCH} - Debian"
uploadArtifacts('Debian', "${DebARCH}", "${VERSION}")
}
}
}
}
// Function to handle Alpine Distro
def jenkinsStepAlpine() {
def temurinVersion = "${TYPE.toLowerCase()} ${VERSION} - ${ARCH}"
def VERSION = "${VERSION}"
echo "Installer Job for Temurin ${temurinVersion} - Alpine"
//make sure this is an array not a string
def apkArchAllList = []
// for one single ARCH add into array
apkArchAllList.add("${ARCH}")
// when ARCH = all, rewrite list
if ("${ARCH}" == 'all') {
apkArchAllList = ['x86_64', 'aarch64']
}
// remove aarch64 for JDK20 and below
def versionInt = VERSION as int // Parse Version As Integer
if (versionInt < 21) {
apkArchAllList.remove('aarch64')
}
apkArchAllList.each { ApkARCH ->
// special handle: no label x86_64 only x64 for alpine agent
def apkLabel = "${ApkARCH}&&docker"
apkLabel = 'x64&&dockerBuild'
if ("${ApkARCH}" == 'x86_64') {
}
// reallocate jenkins agent per element in list
if (ApkARCH == 'x86_64' || ApkARCH == 'aarch64') {
node("linux&&${apkLabel}") {
setup('Alpine', "${ApkARCH}")
tool name: 'jfrog-cli', type: 'jfrog'
unstash 'installercode'
buildAndTest('Alpine', "${ApkARCH}", "${VERSION}")
if (params.uploadPackage.toBoolean()) {
echo "Upload artifacts for ${VERSION} - ${ApkARCH} - Alpine"
uploadArtifacts('Alpine', "${ApkARCH}", "${VERSION}")
}
}
}
}
}
// function handle both RedHat and Suse as DISTRO
def jenkinsStepNonDeb(String DISTRO) {
echo "Installer Job for Temurin jdk ${VERSION} - ${ARCH} - ${DISTRO}"
setup("${DISTRO}", "${ARCH}")
unstash 'installercode'
buildAndTest("${DISTRO}", "${ARCH}", "${VERSION}")
if (params.uploadPackage.toBoolean()) {
echo "Upload artifacts for ${DISTRO} - ${ARCH} - ${VERSION}"
uploadArtifacts("${DISTRO}", "${ARCH}", "${VERSION}")
}
}
// common function regardless DISTRO
def setup(String DISTRO, String buildArch) {
cleanWs()
// Docker --mount option requires BuildKit
env.DOCKER_BUILDKIT = 1
env.COMPOSE_DOCKER_CLI_BUILD = 1
env._JAVA_OPTIONS = (buildArch == 'armv7l' && DISTRO == 'Debian') ? '' : '-Xmx4g'
}
// common function regardless DISTRO
def buildAndTest(String DISTRO, String buildArch, String VERSION) {
try {
if (DISTRO != "Debian") { // for RPM based: RedHat / Suse / Alpine
def privateKey = 'adoptium-artifactory-gpg-key'
if (DISTRO == "Alpine") {
privateKey = 'adoptium-artifactory-rsa-key'
}
if (params.enableGpgSigning) {
// Use Adoptium GPG key for signing
withCredentials([file(credentialsId: privateKey, variable: 'GPG_KEY')]) {
buildCli(DISTRO, buildArch, GPG_KEY, VERSION)
}
} else {
buildCli(DISTRO, buildArch, VERSION)
}
} else {
def gBuildTask = (buildArch == 'x86_64') ? "package${TYPE}${DISTRO} check${TYPE}${DISTRO}" : "package${TYPE}${DISTRO}"
def debArchList = [
'x86_64' : 'amd64',
'armv7l': 'armhf',
'aarch64': 'arm64',
'ppc64le': 'ppc64el',
's390x' : 's390x',
'riscv64' : 'riscv64'
]
switch (VERSION) {
case "8":
debArchList.remove('riscv64')
debArchList.remove('s390x')
break
case "11":
debArchList.remove('riscv64')
break
case "17":
debArchList.remove('riscv64')
break
case "21":
debArchList.remove('armv7l')
break
case "22":
debArchList.remove('armv7l')
break
default:
// Handle Any other cases by defaulting to the main list.
break
}
echo "Build Architecture List = ${debArchList}"
def buildCli = "./gradlew ${gBuildTask} --parallel -PPRODUCT=${env.PRODUCT} -PPRODUCT_VERSION=${VERSION} -PARCH=${debArchList[buildArch]}"
buildCli = params.enableDebug.toBoolean() ? buildCli + ' --stacktrace' : buildCli
sh("$buildCli")
}
} catch (Exception ex) {
echo 'Exception in buildAndTest: ' + ex
currentBuild.result = 'FAILURE' // set the whole pipeline 'red' if build or test fail. Do not use "error" that will not call "finally"
} finally {
// should not allow empty archive, otherwise nothing created in the previous step: package and test result( not needed )
archiveArtifacts artifacts: '**/build/ospackage/*,**/build/reports/**,**/packageTest/dependencies/deb/*', onlyIfSuccessful:false, allowEmptyArchive: false
}
}
private void buildCli(String DISTRO, String buildArch, String GPG_KEY = null, String VERSION) {
def buildCli = "./gradlew package${TYPE}${DISTRO} check${TYPE}${DISTRO} --parallel -PPRODUCT=${env.PRODUCT} -PPRODUCT_VERSION=${VERSION} -PARCH=${buildArch}"
if (GPG_KEY) {
buildCli += " -PGPG_KEY=${GPG_KEY}"
}
if (params.enableDebug.toBoolean()) {
buildCli += " --stacktrace"
}
sh(buildCli)
}
def uploadArtifacts(String DISTRO, String buildArch, String Version) {
switch(DISTRO) {
case "Debian":
uploadDebArtifacts(buildArch, Version)
break
case "Alpine":
uploadAlpineArtifacts(buildArch)
break
default:
uploadRpmArtifacts(DISTRO, buildArch, Version)
break
}
}
def uploadAlpineArtifacts(String buildArch) {
// currently only support x64 & aarch64 as buildArch
// set BUILDARCH environment variable for ${buildArch}
env.BUILDARCH = buildArch
def Distro = "Alpine"
def PackFiles = findFiles(glob: '**/build/ospackage/temurin-*j*.apk') // List All Packages To Upload
def SrcFiles = findFiles(glob: '**/build/ospackage/temurin-*src*.apk') // List All Sources To Upload
def AllFiles = PackFiles + SrcFiles
for (PackFile in AllFiles) {
def FileName = PackFile.name
def Target = "https://adoptium.jfrog.io/artifactory/apk/alpine/main/${BUILDARCH}/${FileName}"
CheckAndUpload(Target, Distro, buildArch, '', '', '', '', '' , FileName)
}
// unset BUILDARCH environment variable
}
def uploadDebArtifacts(String buildArch, String Version) {
env.VERSION = Version
def Distro = "Debian"
def debArchList = [
'x86_64' : 'amd64',
'armv7l': 'armhf',
'aarch64': 'arm64',
'ppc64le': 'ppc64el',
's390x' : 's390x',
'riscv64' : 'riscv64'
]
if (['8', '11', '17', '21', '22'].contains(VERSION)) {
debArchList = [
'x86_64' : 'amd64',
'armv7l': 'armhf',
'aarch64': 'arm64',
'ppc64le': 'ppc64el',
's390x' : 's390x',
'riscv64' : 'riscv64'
]
if (['21', '22'].contains(VERSION)) {
debArchList.remove('armv7l') // Removing armv7l for versions 21 and 22
}
if (VERSION == "8") {
debArchList.remove('s390x') // Removing s390x for version 8
}
} else {
echo "Unsupported version: ${VERSION}"
return // Exit the function for unsupported versions
}
echo "Debian Architecture Upload List = ${debArchList}"
/*
Debian/Ubuntu 10.0 11.0 16.04 20.04 22.04 22.10
add more into list when available for release
also update linux/{jdk,jre}/debian/main/packing/build.sh
*/
def deb_versions = [
"trixie", // Debian/13
"bookworm", // Debian/12
"bullseye", // Debian/11
"buster", // Debian/10
"noble", // Ubuntu/24.04 (LTS)
"jammy", // Ubuntu/22.04 (LTS)
"focal", // Ubuntu/20.04 (LTS)
"bionic" // Ubuntu/18.04 (LTS)
]
def distro_list = ''
deb_versions.each { deb_version ->
// Creates list like deb.distribution=stretch;deb.distribution=buster;
distro_list += "deb.distribution=${deb_version};"
}
for (int i = 0; i < 5; i++) { // loop 5 times at most
echo "Prepare for ${debArchList[buildArch]}.deb"
if(findFiles(glob: "**/build/ospackage/temurin-*${debArchList[buildArch]}.deb").length == 0) {
/*
workaround for error when upload to artifactory: No files were affected in the upload process
might be caused by slow archive done by jenkins
*/
sleep 2
} else {
env.BUILDARCH = debArchList[buildArch]
env.DISTROLIST = distro_list
def PackFiles = findFiles(glob: "**/build/ospackage/temurin-*${debArchList[buildArch]}.deb") // List All Packages To Upload
for (PackFile in PackFiles) {
def FileName = PackFile.name
echo "Prepare For Version = ${VERSION}"
def Target = "https://adoptium.jfrog.io/artifactory/deb/pool/main/t/temurin-${VERSION}/${FileName}"
CheckAndUpload(Target, Distro, BUILDARCH, VERSION, DISTROLIST, '', '', '', '' )
}
}
break
}
}
def uploadRpmArtifacts(String DISTRO, String rpmArch, String Version) {
env.VERSION = Version
def Distro = "RPM"
def distro_Package = [
'redhat' : [
'rpm/centos/7',
'rpm/rocky/8',
'rpm/rhel/7',
'rpm/rhel/8',
'rpm/rhel/9',
'rpm/fedora/35',
'rpm/fedora/36',
'rpm/fedora/37',
'rpm/fedora/38',
'rpm/fedora/39',
'rpm/fedora/40',
'rpm/oraclelinux/7',
'rpm/oraclelinux/8',
'rpm/amazonlinux/2'
],
'suse' : [
'rpm/opensuse/15.3',
'rpm/opensuse/15.4',
'rpm/opensuse/15.5',
'rpm/sles/12',
'rpm/sles/15'
]
]
def packageDirs = distro_Package[DISTRO.toLowerCase()]
def rpmArchList = [
'x86_64': 'x86_64',
'armv7hl': 'armv7hl',
'aarch64': 'aarch64',
'ppc64le': 'ppc64le'
]
if (VERSION == '11') {
rpmArchList['s390x'] = 's390x'
}
if (VERSION == '17') {
rpmArchList['s390x'] = 's390x'
}
if (VERSION == '21') {
rpmArchList['s390x'] = 's390x'
rpmArchList['riscv64'] = 'riscv64'
}
if (VERSION == '22') {
rpmArchList['s390x'] = 's390x'
rpmArchList['riscv64'] = 'riscv64'
}
if ("${rpmArch}" != 'all') {
// when only build and upload one arch, reset
// rpmArchList = [("${rpmArch}" as String): "${rpmArchList[rpmArch]}"]
rpmArchList = [
(rpmArch): (rpmArch)
]
}
// Enable upload src.rpm
if ( params.uploadSRCRPM.toBoolean() || params.DISTRO == 'all' ) {
rpmArchList.put('source', 'src')
}
packageDirs.each { packageDir ->
rpmArchList.each { entry ->
for (int i = 0; i < 5; i++) { // loop 5 times at most
echo "Prepare for ${entry.value}.rpm"
if(findFiles(glob: "**/build/ospackage/*.${entry.value}.rpm").length == 0) {
/*
workaround for error when upload to artifactory: No files were affected in the upload process
might be caused by slow archive done by jenkins
*/
sleep 2
} else {
env.VALUE = entry.value
env.KEY = entry.key
env.PACKAGEDIR = packageDir
def PackFiles = findFiles(glob: "**/build/ospackage/t*.${entry.value}.rpm") // List All Packages To Upload For Temurin
for (PackFile in PackFiles) {
def FileName = PackFile.name
def Target = "https://adoptium.jfrog.io/artifactory/${PACKAGEDIR}/${KEY}/Packages/${FileName}"
CheckAndUpload(Target, Distro, rpmArchList.each, '', '', VALUE , PACKAGEDIR, KEY, '' )
}
break
}
}
}
}
}