This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathJenkinsfile.release
1328 lines (1190 loc) · 37.1 KB
/
Jenkinsfile.release
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
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env groovy
// Libraries
@Library('libelektra-shared') _
// Buildjob properties
properties([
buildDiscarder(
logRotator(
artifactDaysToKeepStr: '31',
artifactNumToKeepStr: '10'
)
),
parameters([
string(
defaultValue: '1',
description: 'Debian package revision.',
name: 'debian_revision',
trim: true
),
string(
defaultValue: '1',
description: 'Ubuntu package revision.',
name: 'ubuntu_revision',
trim: true
),
string(
defaultValue: '1',
description: 'Fedora package revision.',
name: 'fedora_revision',
trim: true
),
string(
defaultValue: '1',
description: 'Alpine Docker image revision.',
name: 'alpine_revision',
trim: true
),
string(
defaultValue: '1',
description: 'Maven package revision.',
name: 'maven_revision',
trim: true
),
booleanParam(
defaultValue: true,
description: 'True if the statistics and hashsums should be automatically inserted into release notes and moved to final name.',
name: 'populate_release_notes'
),
booleanParam(
defaultValue: true,
description: 'True if the source package should be published. Disable when rebuilding to avoid overwriting existing source packages.',
name: 'publish_source_package'
),
booleanParam(
defaultValue: false,
description: 'True if ABI tests with the previous test package should be run.',
name: 'abi_test'
),
string(
defaultValue: '',
description: '[OPTIONAL] Override previous release version. Use if latest git version tag does not correspond to previous released Elektra version.',
name: 'previous_release',
trim: true
)
])
])
pipelineConfig {
// uncomment if you you want to overwrite these values
// dockerNodeLabel = 'docker'
// registry = 'hub.libelektra.org'
now = new Date()
}
DOCKER_IMAGES = [:] // Containers docker image descriptions, populated during
// dockerInit()
RELEASE_VERSION = '' // Release version, set during release build and used
// by the documentation stage
PREVIOUS_RELEASE_VERSION = '' // Version of previous Elektra release
RELEASE_ARTIFACT_STAGES = [] // Main release stage names, populated during buildRelease().
// Used to reference the artifacts of these stages
// Stages
stage('Init docker images') {
dockerInit()
}
stage ('Init release environment') {
initVariables()
}
stage('Pull docker images') {
parallel dockerUtils.generateDockerPullStages(DOCKER_IMAGES)
}
maybeStage('Build docker images', DOCKER_IMAGES.any { img -> !img.value.exists }) {
lock('docker-images') {
parallel dockerUtils.generateDockerBuildStages(DOCKER_IMAGES)
}
}
stage('Release') {
milestone label: 'Release'
parallel generateReleaseStages()
}
stage('Build website and docker images for package testing') {
parallel generateDockerBuildStagesWithPackagesInstalled()
}
stage('Test packages') {
parallel generateInstalledPackagesTestStages()
}
maybeStage('Build ABI images', params.abi_test) {
parallel generateAbiImages()
}
maybeStage('ABI tests', params.abi_test) {
parallel generateAbiTestStages()
}
// Pause pipeline and wait for approval to run publishing steps
input(message: 'Publish Release?', ok: 'Yes')
stage('Publish') {
parallel generatePublishStages()
}
stage('Main repository and website publish') {
parallel generateFinalPublishStages()
}
stage('Upload release Docker images') {
parallel generateImageUploadStages()
}
/**************/
/* Generators */
/**************/
/**
* Determine previous released Elektra version
*
* Defaults to latest git version tag.
* Can be overriden by passing a specific version for parameter 'previous_release'
*/
def initVariables() {
node('master') {
checkout scm
if (params.previous_release?.trim()) {
PREVIOUS_RELEASE_VERSION = params.previous_release
} else {
script {
PREVIOUS_RELEASE_VERSION = sh(
script: "git tag -l --sort=version:refname | sed 's/v//' | grep -e '[0-9].[0-9].[0-9]*' | tail -n1",
returnStdout: true
).trim()
}
}
echo "PREVIOUS_RELEASE_VERSION: ${PREVIOUS_RELEASE_VERSION}"
}
}
/**
* Populate DOCKER_IMAGES with data
*
* For this we need a checkout of the scm to generate the hash for the
* Dockerfiles which indicates if a rebuild of the images is needed
*/
def dockerInit() {
node('master') {
echo 'Processing DOCKER_IMAGES'
checkout scm
/* Test and build release artifacts with these images. */
DOCKER_IMAGES.buster = dockerUtils.createDockerImageDesc(
'debian-buster', dockerUtils.&idTesting,
'./scripts/docker/debian/buster',
'./scripts/docker/debian/buster/Dockerfile'
)
DOCKER_IMAGES.bullseye = dockerUtils.createDockerImageDesc(
'debian-bullseye', dockerUtils.&idTesting,
'./scripts/docker/debian/bullseye',
'./scripts/docker/debian/bullseye/Dockerfile'
)
DOCKER_IMAGES.focal = dockerUtils.createDockerImageDesc(
'ubuntu-focal', dockerUtils.&idTesting,
'./scripts/docker/ubuntu/focal',
'./scripts/docker/ubuntu/focal/Dockerfile'
)
DOCKER_IMAGES.jammy = dockerUtils.createDockerImageDesc(
'ubuntu-jammy', dockerUtils.&idTesting,
'./scripts/docker/ubuntu/jammy',
'./scripts/docker/ubuntu/jammy/Dockerfile'
)
DOCKER_IMAGES.kinetic = dockerUtils.createDockerImageDesc(
'ubuntu-kinetic', dockerUtils.&idTesting,
'./scripts/docker/ubuntu/kinetic',
'./scripts/docker/ubuntu/kinetic/Dockerfile'
)
DOCKER_IMAGES.fedora_36 = dockerUtils.createDockerImageDesc(
'fedora-36', dockerUtils.&idTesting,
'./scripts/docker/fedora/36',
'./scripts/docker/fedora/36/Dockerfile'
)
DOCKER_IMAGES.fedora_37 = dockerUtils.createDockerImageDesc(
'fedora-37', dockerUtils.&idTesting,
'./scripts/docker/fedora/37',
'./scripts/docker/fedora/37/Dockerfile'
)
DOCKER_IMAGES.opensuse_15_3 = dockerUtils.createDockerImageDesc(
"opensuse-15-3", dockerUtils.&idTesting,
"./scripts/docker/opensuse/15.3",
"./scripts/docker/opensuse/15.3/Dockerfile"
)
/* Install and test the built packages with theses images. */
DOCKER_IMAGES.buster_installed = dockerUtils.createDockerImageDesc(
'debian-buster-installed', dockerUtils.&idArtifact,
'./release-artifact/*/package/buster/',
'./scripts/docker/debian/buster/package.Dockerfile',
false
)
DOCKER_IMAGES.bullseye_installed = dockerUtils.createDockerImageDesc(
'debian-bullseye-installed', dockerUtils.&idArtifact,
'./release-artifact/*/package/bullseye/',
'./scripts/docker/debian/bullseye/package.Dockerfile',
false
)
DOCKER_IMAGES.focal_installed = dockerUtils.createDockerImageDesc(
'ubuntu-focal-installed', dockerUtils.&idArtifact,
'./release-artifact/*/package/focal/',
'./scripts/docker/ubuntu/focal/package.Dockerfile',
false
)
DOCKER_IMAGES.jammy_installed = dockerUtils.createDockerImageDesc(
'ubuntu-jammy-installed', dockerUtils.&idArtifact,
'./release-artifact/*/package/jammy/',
'./scripts/docker/ubuntu/jammy/package.Dockerfile',
false
)
DOCKER_IMAGES.kinetic_installed = dockerUtils.createDockerImageDesc(
'ubuntu-kinetic-installed', dockerUtils.&idArtifact,
'./release-artifact/*/package/kinetic/',
'./scripts/docker/ubuntu/kinetic/package.Dockerfile',
false
)
DOCKER_IMAGES.fedora_36_installed = dockerUtils.createDockerImageDesc(
'fedora-36-installed', dockerUtils.&idArtifact,
'./release-artifact/*/package/fedora36/',
'./scripts/docker/fedora/36/package.Dockerfile',
false
)
DOCKER_IMAGES.fedora_37_installed = dockerUtils.createDockerImageDesc(
'fedora-37-installed', dockerUtils.&idArtifact,
'./release-artifact/*/package/fedora37/',
'./scripts/docker/fedora/37/package.Dockerfile',
false
)
DOCKER_IMAGES.opensuse_15_3_installed = dockerUtils.createDockerImageDesc(
'opensuse-15-3-installed', dockerUtils.&idArtifact,
'./release-artifact/*/package/opensuse-leap15.3/',
'./scripts/docker/opensuse/15.3/package.Dockerfile',
false
)
/* Install packages for Docker image release */
DOCKER_IMAGES.buster_release = createDockerImageDescForRelease(
'elektra/elektra',
'./release-artifact/*/package/buster/',
'./scripts/docker/debian/buster/release.Dockerfile',
false
)
DOCKER_IMAGES.bullseye_release = createDockerImageDescForRelease(
'elektra/elektra',
'./release-artifact/*/package/bullseye/',
'./scripts/docker/debian/bullseye/release.Dockerfile',
false
)
DOCKER_IMAGES.focal_release = createDockerImageDescForRelease(
'elektra/elektra',
'./release-artifact/*/package/focal/',
'./scripts/docker/ubuntu/focal/release.Dockerfile',
false
)
DOCKER_IMAGES.jammy_release = createDockerImageDescForRelease(
'elektra/elektra',
'./release-artifact/*/package/jammy/',
'./scripts/docker/ubuntu/jammy/release.Dockerfile',
false
)
DOCKER_IMAGES.kinetic_release = createDockerImageDescForRelease(
'elektra/elektra',
'./release-artifact/*/package/kinetic/',
'./scripts/docker/ubuntu/kinetic/release.Dockerfile',
false
)
DOCKER_IMAGES.fedora_36_release = createDockerImageDescForRelease(
'elektra/elektra',
'./release-artifact/*/package/fedora36/',
'./scripts/docker/fedora/36/release.Dockerfile',
false
)
DOCKER_IMAGES.fedora_37_release = createDockerImageDescForRelease(
'elektra/elektra',
'./release-artifact/*/package/fedora37/',
'./scripts/docker/fedora/37/release.Dockerfile',
false
)
DOCKER_IMAGES.opensuse_15_3_release = createDockerImageDescForRelease(
'elektra/elektra',
'./release-artifact/*/package/opensuse-leap15.3/',
'./scripts/docker/opensuse/15.3/release.Dockerfile',
false
)
/* Build Elektra's documentation with this image.
* Also contains latex for pdf creation.
*/
DOCKER_IMAGES.bullseye_doc = dockerUtils.createDockerImageDesc(
'debian-bullseye-doc', dockerUtils.&idTesting,
'./scripts/docker/debian/bullseye',
'./scripts/docker/debian/bullseye/doc.Dockerfile'
)
/*
* Alpine release image with installed Elektra
*/
DOCKER_IMAGES.alpine_release = createDockerImageDescForRelease(
'elektra/elektra',
'./scripts/docker/alpine/*',
'./scripts/docker/alpine/*/release.Dockerfile',
false
)
/* Image building the libelektra.org website */
DOCKER_IMAGES.website = dockerUtils.createDockerImageDesc(
"website-release", dockerUtils.&idArtifact,
".",
"./scripts/docker/website/Dockerfile",
false
)
/*
* ABI test images
*/
DOCKER_IMAGES.fedora_37_abi = dockerUtils.createDockerImageDesc(
'fedora-37-abi', dockerUtils.&idArtifact,
'./release-artifact/*/package/fedora37/',
'./scripts/docker/fedora/37/abi.Dockerfile',
false
)
DOCKER_IMAGES.bullseye_abi = dockerUtils.createDockerImageDesc(
'debian-bullseye-abi', dockerUtils.&idArtifact,
'./release-artifact/*/package/bullseye/',
'./scripts/docker/debian/bullseye/abi.Dockerfile',
false
)
}
}
/**
* Generate release stages for release automation
*/
def generateReleaseStages() {
def tasks = [:]
tasks << buildRelease(
'debian-buster',
DOCKER_IMAGES.buster,
params.debian_revision
)
tasks << buildRelease(
'debian-bullseye',
DOCKER_IMAGES.bullseye,
params.debian_revision,
true // bundle repository
)
tasks << buildRelease(
'ubuntu-focal',
DOCKER_IMAGES.focal,
params.ubuntu_revision
)
tasks << buildRelease(
'ubuntu-jammy',
DOCKER_IMAGES.jammy,
params.ubuntu_revision
)
tasks << buildRelease(
'ubuntu-kinetic',
DOCKER_IMAGES.kinetic,
params.ubuntu_revision
)
tasks << buildRelease(
'fedora-36',
DOCKER_IMAGES.fedora_36,
params.fedora_revision,
false, // do not bundle git repo
true // use placeholder dirs
)
tasks << buildRelease(
'fedora-37',
DOCKER_IMAGES.fedora_37,
params.fedora_revision,
false, // do not bundle git repo
true // use placeholder dirs
)
tasks << buildAndTestMingwW64_x86_64()
tasks << buildAndTestMingwW64_i686()
tasks << buildRelease(
'opensuse-15-3',
DOCKER_IMAGES.opensuse_15_3,
params.fedora_revision,
false, // do not bundle git repo
true // use placeholder dirs
)
return tasks
}
/**
* Generate Docker Build Stages with installed libelektra packages
*/
def generateDockerBuildStagesWithPackagesInstalled() {
def tasks = [:]
tasks << buildImageWithPackagesStage(
DOCKER_IMAGES.focal_installed,
'ubuntu-focal'
)
tasks << buildImageWithPackagesStage(
DOCKER_IMAGES.jammy_installed,
'ubuntu-jammy'
)
tasks << buildImageWithPackagesStage(
DOCKER_IMAGES.kinetic_installed,
'ubuntu-kinetic'
)
tasks << buildImageWithPackagesStage(
DOCKER_IMAGES.fedora_36_installed,
'fedora-36'
)
tasks << buildImageWithPackagesStage(
DOCKER_IMAGES.fedora_37_installed,
'fedora-37'
)
tasks << buildImageWithPackagesStage(
DOCKER_IMAGES.buster_installed,
'debian-buster'
)
tasks << buildImageWithPackagesStage(
DOCKER_IMAGES.bullseye_installed,
'debian-bullseye'
)
tasks << buildImageWithPackagesStage(
DOCKER_IMAGES.opensuse_15_3_installed,
'opensuse-15-3'
)
// build website
tasks << buildWebsite('debian-bullseye')
return tasks
}
/**
* Generates Testing stages where installed packages are tested
*/
def generateInstalledPackagesTestStages() {
def tasks = [:]
tasks << testInstalledPackage(
'ubuntu-focal-installed',
DOCKER_IMAGES.focal_installed
)
tasks << testInstalledPackage(
'ubuntu-jammy-installed',
DOCKER_IMAGES.jammy_installed
)
tasks << testInstalledPackage(
'ubuntu-kinetic-installed',
DOCKER_IMAGES.kinetic_installed
)
tasks << testInstalledPackage(
'fedora-36-installed',
DOCKER_IMAGES.fedora_36_installed
)
tasks << testInstalledPackage(
'fedora-37-installed',
DOCKER_IMAGES.fedora_37_installed
)
tasks << testInstalledPackage(
'debian-buster-installed',
DOCKER_IMAGES.buster_installed
)
tasks << testInstalledPackage(
'debian-bullseye-installed',
DOCKER_IMAGES.bullseye_installed
)
tasks << testInstalledPackage(
'opensuse-15-3-installed',
DOCKER_IMAGES.opensuse_15_3_installed
)
return tasks
}
def generateAbiImages() {
// build abi images
tasks << buildImageWithPackagesStage(
DOCKER_IMAGES.fedora_37_abi,
'fedora-37'
)
tasks << buildImageWithPackagesStage(
DOCKER_IMAGES.bullseye_abi,
'debian-bullseye'
)
return tasks
}
def generateAbiTestStages() {
def tasks = [:]
tasks << testAbiPackage(
'fedora-37-abi',
DOCKER_IMAGES.fedora_37_abi
)
tasks << testAbiPackage(
'debian-bullseye-abi',
DOCKER_IMAGES.bullseye_abi
)
return tasks
}
/**
* Generates stages to publish deb packages
*/
def generateDebPackagePublishStages() {
def tasks = [:]
tasks << publish(
'debian-buster',
'buster',
'buster',
'buster',
release.&publishDebPackages,
params.debian_revision
)
tasks << publish(
'debian-bullseye',
'bullseye',
'bullseye',
'bullseye',
release.&publishDebPackages,
params.debian_revision
)
tasks << publish(
'ubuntu-focal',
'focal',
'focal',
'focal',
release.&publishDebPackages,
params.ubuntu_revision
)
tasks << publish(
'ubuntu-jammy',
'jammy',
'jammy',
'jammy',
release.&publishDebPackages,
params.ubuntu_revision
)
tasks << publish(
'ubuntu-kinetic',
'kinetic',
'kinetic',
'kinetic',
release.&publishDebPackages,
params.ubuntu_revision
)
return tasks
}
/**
* Runs the debian package stages sequential
*
* Necessary to prevent race conditions from `aptly`.
*/
def publishDebPackagesStage() {
def stageName = 'publish-deb'
return [(stageName): {
stage(stageName) {
sequential generateDebPackagePublishStages()
}
}]
}
/**
* Generate Publish Stages
*/
def generatePublishStages() {
def tasks = [:]
tasks << publishDebPackagesStage()
// RPM packges can be published in parallel because
// no shared DB is used.
tasks << publish(
'fedora-36',
'fedora36',
'fedora-36',
'fedora-36',
release.&publishRpmPackages,
params.fedora_revision
)
tasks << publish(
'fedora-37',
'fedora37',
'fedora-37',
'fedora-37',
release.&publishRpmPackages,
params.fedora_revision
)
tasks << publish(
'opensuse-15-3',
'opensuse-leap15.3',
'opensuse-leap-15.3',
'opensuse-leap-15.3',
release.&publishRpmPackages,
params.fedora_revision
)
tasks << buildDoc()
// publish source package built in debian-bullseye stage
if (params.publish_source_package) {
tasks << publishSource('debian-bullseye')
}
tasks << buildAndPublishMaven()
return tasks
}
/* Helper to generate mingw x86_64 test */
def buildAndTestMingwW64_x86_64() {
def testName = "debian-bullseye-mingw-w64-x86_64"
return [(testName): {
stage(testName) {
withDockerEnv(DOCKER_IMAGES.bullseye) {
dir('build') {
deleteDir()
sh '../scripts/dev/configure-mingw-w64-x86_64 ..'
sh 'make'
def destdir='elektra'
withEnv(["DESTDIR=${destdir}"]){
sh 'make install'
}
sh "zip -r elektra.zip ${destdir}"
utils.archive(['elektra.zip'])
}
}
}
}]
}
/* Helper to generate mingw i686 test */
def buildAndTestMingwW64_i686() {
def testName = "debian-bullseye-mingw-w64-i686"
return [(testName): {
stage(testName) {
withDockerEnv(DOCKER_IMAGES.bullseye) {
dir('build') {
deleteDir()
sh '../scripts/dev/configure-mingw-w64-i686 ..'
sh 'make'
def destdir='elektra'
withEnv(["DESTDIR=${destdir}"]){
sh 'make install'
}
sh "zip -r elektra.zip ${destdir}"
utils.archive(['elektra.zip'])
}
}
}
}]
}
def generateFinalPublishStages() {
def tasks = [:]
// publish main repo which got modified during the
// debian-bullseye release stage
tasks << publishMainRepo('debian-bullseye')
// publish website
tasks << release.deployWebsite(DOCKER_IMAGES.website)
return tasks
}
/**
* Generate stages that upload release Docker images
*/
def generateImageUploadStages() {
def tasks = [:]
tasks << publishImage(
DOCKER_IMAGES.alpine_release,
null, // no artifacts need to be imported
params.alpine_revision,
'alpine',
true // additionally tag with 'latest'
)
tasks << publishImage(
DOCKER_IMAGES.focal_release,
'ubuntu-focal',
ubuntu_revision,
'focal'
)
tasks << publishImage(
DOCKER_IMAGES.jammy_release,
'ubuntu-jammy',
ubuntu_revision,
'jammy'
)
tasks << publishImage(
DOCKER_IMAGES.kinetic_release,
'ubuntu-kinetic',
ubuntu_revision,
'kinetic'
)
tasks << publishImage(
DOCKER_IMAGES.fedora_36_release,
'fedora-36',
fedora_revision,
'fedora36'
)
tasks << publishImage(
DOCKER_IMAGES.fedora_37_release,
'fedora-37',
fedora_revision,
'fedora37'
)
tasks << publishImage(
DOCKER_IMAGES.buster_release,
'debian-buster',
debian_revision,
'buster'
)
tasks << publishImage(
DOCKER_IMAGES.bullseye_release,
'debian-bullseye',
debian_revision,
'bullseye'
)
tasks << publishImage(
DOCKER_IMAGES.opensuse_15_3_release,
'opensuse-15-3',
fedora_revision,
'opensuse-leap-15.3'
)
return tasks
}
/**
* Release stage
*
* Imports the gpg keys and runs the release script.
* All relevant artifacts (build and test infos, packages, etc) are archived.
* The Elektra version is queried and assigned to the pipeline
* variable `RELEASE_VERSION`
*
* @param stageName used to identify the release and name the stage
* @param image which docker image should be used
* @param bundleRepo if the libelektra repository should be bundled and archived
* @param placeholderDir if placeholder directories should be used to extend
* the base path
*/
def buildRelease(stageName, image, packageRevision='1',
bundleRepo=false, placeholderDir=false) {
return [(stageName): {
stage(stageName) {
withDockerEnv(image, [DockerOpts.MOUNT_MIRROR, DockerOpts.NO_CHECKOUT]) {
withCredentials([file(credentialsId: 'jenkins-key', variable: 'KEY'),
file(credentialsId: 'jenkins-secret-key', variable: 'SKEY')]) {
sh "gpg --import $KEY"
sh "gpg --import $SKEY"
sh "mkdir -p ${WORKSPACE}/config/kdb/system || /bin/true"
sh "mkdir -p ${WORKSPACE}/config/kdb/spec || /bin/true"
sh "mkdir -p ${WORKSPACE}/config/kdb/home || /bin/true"
configureGitUser()
def dirStructure = './'
if (placeholderDir) {
dirStructure = dirStructure + 'placeholder/placeholder/placeholder/placeholder'
}
dir(dirStructure) {
dir('libelektra') {
deleteDir()
checkout scm
}
dir('ftp') {
deleteDir()
git branch: 'master',
url: 'https://github.com/ElektraInitiative/ftp.git'
}
dir('prev-release-logs') {
sh "cp -R ../ftp/release-logs/${PREVIOUS_RELEASE_VERSION}/${stageName}/* ./ || touch installed_files"
}
sh "sh libelektra/scripts/release/release.sh ${packageRevision} ${PREVIOUS_RELEASE_VERSION}"
sh "mv release.tar.gz ${stageName}-release.tar.gz"
utils.archive(["${stageName}-release.tar.gz"])
RELEASE_ARTIFACT_STAGES << stageName
script {
RELEASE_VERSION = sh(
script: "sh libelektra/scripts/release/get-installed-version.sh | sed 's/v//'",
returnStdout: true
).trim()
}
dir('libelektra') {
if (params.populate_release_notes) {
sh "scripts/release/populate-release-notes.sh ${RELEASE_VERSION} ../${RELEASE_VERSION}/"
sh "git add doc/news"
sh "git add scripts/docker/alpine"
sh "git commit -m 'release: add hashsums and statistics to release notes, update alpine release image'"
}
if (bundleRepo) {
sh 'git bundle create libelektra.bundle --all'
utils.archive(['libelektra.bundle'])
}
}
}
deleteDir()
}
}
}
}]
}
/**
* Tests installed packages in docker container and archives results
*
* @param stageName used to identify the stage
* @param image which docker image should be used
*/
def testInstalledPackage(stageName, image) {
return [(stageName): {
stage(stageName) {
withDockerEnv(image, [DockerOpts.MOUNT_MIRROR]) {
checkout scm
sh "./scripts/release/release-tests.sh ./ ${RELEASE_VERSION} package OFF"
sh "tar -czvf ${stageName}-release.tar.gz ./${RELEASE_VERSION}"
utils.archive(["${stageName}-release.tar.gz"])
deleteDir()
}
}
}]
}
def testAbiPackage(stageName, image) {
return [(stageName): {
stage(stageName) {
withDockerEnv(image, [DockerOpts.MOUNT_MIRROR]) {
checkout scm
sh "CHECK_VERSION=NO kdb run_all"
deleteDir()
}
}
}]
}
/**
* Publish changes and artifacts
*
* @param correspondingReleaseStageName corresponding name of the test stage in which artifcats
* necessary for this stage have been generated
* @param context filepath under which packages are located
* @param repoName name of the package repository
* @param repoPrefix prefix of the package repository
* @param publishPackagesFun closure that publishes packages to a repository
* @param packageRevision revision number of the package
*/
def publish(correspondingReleaseStageName, context, repoName,
repoPrefix, publishPackagesFun, packageRevision) {
return [(correspondingReleaseStageName): {
stage(correspondingReleaseStageName) {
withDockerEnv(DOCKER_IMAGES.bullseye) {
copyReleaseArtifact(correspondingReleaseStageName)
dir('copy') {
deleteDir()
sh "mv ../release-artifact/${RELEASE_VERSION}/package/${context}/* ./"
publishPackagesFun(
'doc.libelektra.org',
"/packaging/incoming/${repoName}/",
repoName,
repoPrefix,
RELEASE_VERSION,
packageRevision
)
}
}
}
}]
}
/**
* Publish source package to ftp repo
*
* @param artifactStageName artifact to get source package from
*/
def publishSource(artifactStageName) {
def stageName = 'publishSourcePackage'
return [(stageName): {
stage(stageName) {
withDockerEnv(DOCKER_IMAGES.bullseye) {
configureGitUser()
copyReleaseArtifact(artifactStageName)
dir('ftp') {
deleteDir()
git branch: 'master',
url: 'https://github.com/ElektraInitiative/ftp.git'
// move release tarball to git
sh 'cp ../release-artifact/*/*.tar.gz* ./releases/'
sh 'git add ./releases'
// move release logs to git
RELEASE_ARTIFACT_STAGES.each {
dir ('../') {
sh 'rm -rf ./release-artifact'
copyReleaseArtifact(it)
// remove package directory so it doesn't get copied
sh 'rm -rf ./release-artifact/*/package'
sh 'rm -rf ./release-artifact/*/*.tar.gz*'
}
sh "mkdir -p ./release-logs/${RELEASE_VERSION}/${it}/"
sh "mv ../release-artifact/*/* ./release-logs/${RELEASE_VERSION}/${it}/"
}
sh 'git add ./release-logs'
sh "git commit -a -m 'release: add ${RELEASE_VERSION}'"
pushGitRepo('ftp')
withCredentials([sshUserPrivateKey(credentialsId: "community-ssh-git", keyFileVariable: "privateSshKey", usernameVariable: 'GIT_USERNAME')]) {
// add community server to known hosts
sh "mkdir -p ~/.ssh/ && ssh-keyscan -t rsa doc.libelektra.org >> ~/.ssh/known_hosts"
// add community mirror of ftp repo as remote
sh "git remote add community ${GIT_USERNAME}@doc.libelektra.org:/srv/elektra"