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
|
#!groovy
//
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
build_and_test = '''
mkdir -p ${COUCHDB_IO_LOG_DIR} ${platform}
cd ${platform}
rm -rf build
mkdir build
cd build
tar -xf ${WORKSPACE}/apache-couchdb-*.tar.gz
cd apache-couchdb-*
./configure --with-curl --spidermonkey-version ${sm_ver}
make check || (make build-report && false)
'''
make_packages = '''
cd ${platform}
git clone https://github.com/apache/couchdb-pkg
rm -rf couchdb
mkdir couchdb
cp ${WORKSPACE}/apache-couchdb-*.tar.gz couchdb
tar -xf ${WORKSPACE}/apache-couchdb-*.tar.gz -C couchdb
cd couchdb-pkg
make ${platform} PLATFORM=${platform}
'''
cleanup_and_save = '''
rm -rf ${WORKSPACE}/pkgs/${platform}
mkdir -p ${WORKSPACE}/pkgs/${platform}
mv ${WORKSPACE}/${platform}/rpmbuild/RPMS/$(arch)/*rpm ${WORKSPACE}/pkgs/${platform} || true
mv ${WORKSPACE}/${platform}/couchdb/*.deb ${WORKSPACE}/pkgs/${platform} || true
'''
update_qemu = '''
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
'''
pipeline {
// no top-level agent; agents must be declared for each stage
agent none
environment {
COUCHAUTH = credentials('couchdb_vm2_couchdb')
recipient = 'notifications@couchdb.apache.org'
COUCHDB_IO_LOG_DIR = '/tmp/couchjslogs'
// Following fix an issue with git <= 2.6.5 where no committer
// name or email are present for reflog, required for git clone
GIT_COMMITTER_NAME = 'Jenkins User'
GIT_COMMITTER_EMAIL = 'couchdb@apache.org'
// https://github.com/jenkins-infra/jenkins.io/blob/master/Jenkinsfile#64
// We need the jenkins user mapped inside of the image
// npm config cache below deals with /home/jenkins not mapping correctly
// inside the image
DOCKER_ARGS = '-e npm_config_cache=npm-cache -e HOME=. -v=/etc/passwd:/etc/passwd -v /etc/group:/etc/group'
}
options {
buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '10'))
// This fails the build immediately if any parallel step fails
parallelsAlwaysFailFast()
preserveStashes(buildCount: 10)
timeout(time: 3, unit: 'HOURS')
timestamps()
}
stages {
stage('Build Release Tarball') {
agent {
docker {
label 'docker'
image 'couchdbdev/debian-stretch-erlang-20.3.8.24-1:latest'
args "${DOCKER_ARGS}"
alwaysPull true
}
}
options {
timeout(time: 15, unit: "MINUTES")
}
steps {
sh '''
set
rm -rf apache-couchdb-*
./configure --with-curl
make dist
chmod -R a+w * .
'''
}
post {
success {
stash includes: 'apache-couchdb-*.tar.gz', name: 'tarball'
archiveArtifacts artifacts: 'apache-couchdb-*.tar.gz', fingerprint: true
}
cleanup {
// UGH see https://issues.jenkins-ci.org/browse/JENKINS-41894
sh 'rm -rf ${WORKSPACE}/*'
}
}
} // stage Build Release Tarball
// TODO Rework once Improved Docker Pipeline Engine is released
// https://issues.jenkins-ci.org/browse/JENKINS-47962
// https://issues.jenkins-ci.org/browse/JENKINS-48050
stage('Test and Package') {
options {
skipDefaultCheckout()
timeout(time: 90, unit: "MINUTES")
}
parallel {
stage('FreeBSD') {
agent {
label 'freebsd'
}
steps {
// deleteDir is OK here because we're not inside of a Docker container!
deleteDir()
unstash 'tarball'
withEnv(['HOME='+pwd()]) {
sh '''
mkdir -p $COUCHDB_IO_LOG_DIR
# Build CouchDB from tarball & test
mkdir build
cd build
tar -xf $WORKSPACE/apache-couchdb-*.tar.gz
cd apache-couchdb-*
./configure --with-curl
gmake check || (build-aux/logfile-uploader.py && false)
# No package build for FreeBSD at this time
'''
} // withEnv
} // steps
post {
always {
junit '**/.eunit/*.xml, **/_build/*/lib/couchdbtest/*.xml, **/src/mango/nosetests.xml, **/test/javascript/junit.xml'
}
cleanup {
sh 'rm -rf $COUCHDB_IO_LOG_DIR'
}
} // post
} // stage FreeBSD
stage('CentOS 6') {
agent {
docker {
image 'couchdbdev/centos-6-erlang-20.3.8.24-1:latest'
label 'docker'
args "${DOCKER_ARGS}"
alwaysPull true
}
}
environment {
platform = 'centos6'
sm_ver = '1.8.5'
}
stages {
stage('Build from tarball & test') {
steps {
unstash 'tarball'
sh( script: build_and_test )
}
post {
always {
junit '**/.eunit/*.xml, **/_build/*/lib/couchdbtest/*.xml, **/src/mango/nosetests.xml, **/test/javascript/junit.xml'
}
}
}
stage('Build CouchDB packages') {
steps {
sh( script: make_packages )
sh( script: cleanup_and_save )
}
post {
success {
archiveArtifacts artifacts: 'pkgs/**', fingerprint: true
}
}
}
} // stages
post {
cleanup {
sh 'rm -rf ${WORKSPACE}/*'
}
} // post
} // stage
stage('CentOS 7') {
agent {
docker {
image 'couchdbdev/centos-7-erlang-20.3.8.24-1:latest'
label 'docker'
args "${DOCKER_ARGS}"
alwaysPull true
}
}
environment {
platform = 'centos7'
sm_ver = '1.8.5'
}
stages {
stage('Build from tarball & test') {
steps {
unstash 'tarball'
sh( script: build_and_test )
}
post {
always {
junit '**/.eunit/*.xml, **/_build/*/lib/couchdbtest/*.xml, **/src/mango/nosetests.xml, **/test/javascript/junit.xml'
}
}
}
stage('Build CouchDB packages') {
steps {
unstash 'tarball'
sh( script: make_packages )
sh( script: cleanup_and_save )
}
post {
success {
archiveArtifacts artifacts: 'pkgs/**', fingerprint: true
}
}
}
} // stages
post {
cleanup {
sh 'rm -rf ${WORKSPACE}/*'
}
} // post
} // stage
stage('CentOS 8') {
agent {
docker {
image 'couchdbdev/centos-8-erlang-20.3.8.24-1:latest'
label 'docker'
args "${DOCKER_ARGS}"
alwaysPull true
}
}
environment {
platform = 'centos8'
sm_ver = '1.8.5'
}
stages {
stage('Build from tarball & test') {
steps {
unstash 'tarball'
sh( script: build_and_test )
}
post {
always {
junit '**/.eunit/*.xml, **/_build/*/lib/couchdbtest/*.xml, **/src/mango/nosetests.xml, **/test/javascript/junit.xml'
}
}
}
stage('Build CouchDB packages') {
steps {
unstash 'tarball'
sh( script: make_packages )
sh( script: cleanup_and_save )
}
post {
success {
archiveArtifacts artifacts: 'pkgs/**', fingerprint: true
}
}
}
} // stages
post {
cleanup {
sh 'rm -rf ${WORKSPACE}/*'
}
} // post
} // stage
stage('Ubuntu Xenial') {
agent {
docker {
image 'couchdbdev/ubuntu-xenial-erlang-20.3.8.24-1:latest'
label 'docker'
args "${DOCKER_ARGS}"
alwaysPull true
}
}
environment {
platform = 'xenial'
sm_ver = '1.8.5'
}
stages {
stage('Build from tarball & test') {
steps {
unstash 'tarball'
sh( script: build_and_test )
}
post {
always {
junit '**/.eunit/*.xml, **/_build/*/lib/couchdbtest/*.xml, **/src/mango/nosetests.xml, **/test/javascript/junit.xml'
}
}
}
stage('Build CouchDB packages') {
steps {
sh( script: make_packages )
sh( script: cleanup_and_save )
}
post {
success {
archiveArtifacts artifacts: 'pkgs/**', fingerprint: true
}
}
}
} // stages
post {
cleanup {
sh 'rm -rf ${WORKSPACE}/*'
}
} // post
} // stage
stage('Ubuntu Bionic') {
agent {
docker {
image 'couchdbdev/ubuntu-bionic-erlang-20.3.8.24-1:latest'
label 'docker'
alwaysPull true
args "${DOCKER_ARGS}"
}
}
environment {
platform = 'bionic'
sm_ver = '1.8.5'
}
stages {
stage('Build from tarball & test') {
steps {
unstash 'tarball'
sh( script: build_and_test )
}
post {
always {
junit '**/.eunit/*.xml, **/_build/*/lib/couchdbtest/*.xml, **/src/mango/nosetests.xml, **/test/javascript/junit.xml'
}
}
}
stage('Build CouchDB packages') {
steps {
sh( script: make_packages )
sh( script: cleanup_and_save )
}
post {
success {
archiveArtifacts artifacts: 'pkgs/**', fingerprint: true
}
}
}
} // stages
post {
cleanup {
sh 'rm -rf ${WORKSPACE}/*'
}
} // post
} // stage
stage('Debian Stretch') {
agent {
docker {
image 'couchdbdev/debian-stretch-erlang-20.3.8.24-1:latest'
label 'docker'
alwaysPull true
args "${DOCKER_ARGS}"
}
}
environment {
platform = 'stretch'
sm_ver = '1.8.5'
}
stages {
stage('Build from tarball & test') {
steps {
unstash 'tarball'
sh( script: build_and_test )
}
post {
always {
junit '**/.eunit/*.xml, **/_build/*/lib/couchdbtest/*.xml, **/src/mango/nosetests.xml, **/test/javascript/junit.xml'
}
}
}
stage('Build CouchDB packages') {
steps {
sh( script: make_packages )
sh( script: cleanup_and_save )
}
post {
success {
archiveArtifacts artifacts: 'pkgs/**', fingerprint: true
}
}
}
} // stages
post {
cleanup {
sh 'rm -rf ${WORKSPACE}/*'
}
} // post
} // stage
stage('Debian Buster amd64') {
agent {
docker {
image 'couchdbdev/debian-buster-erlang-20.3.8.24-1:latest'
label 'docker'
alwaysPull true
args "${DOCKER_ARGS}"
}
}
environment {
platform = 'buster'
sm_ver = '60'
}
stages {
stage('Build from tarball & test') {
steps {
unstash 'tarball'
sh( script: build_and_test )
}
post {
always {
junit '**/.eunit/*.xml, **/_build/*/lib/couchdbtest/*.xml, **/src/mango/nosetests.xml, **/test/javascript/junit.xml'
}
}
}
stage('Build CouchDB packages') {
steps {
sh( script: make_packages )
sh( script: cleanup_and_save )
}
post {
success {
archiveArtifacts artifacts: 'pkgs/**', fingerprint: true
}
}
}
} // stages
post {
cleanup {
sh 'rm -rf ${WORKSPACE}/*'
}
} // post
} // stage
/*
*
* This is just taking too long to run. Right now, the khash tests are timing out
* on the IBM servers:
*
* [2019-12-31T20:58:48.704Z] khash randomized test
* [2019-12-31T20:59:04.869Z] khash_test:103: randomized_test_ (State matches dict implementation)...*timed out*
*
* So, this is DISABLED until we get an actual arm builder machine.
*
* ppc64le is actually slower to emulate than arm, so we're not even going to try that.
*/
/*
stage('Debian Buster arm64v8') {
// once we have an arm64v8 node again, can restore this to original form that is less ugly
// the process is convoluted to ensure we have the latest qemu static binaries on the node first
// before trying to run a foreign docker container type. Alternately ensuring the `update_qemu`
// container is run on every Jenkins agent *after every restart of the Docker daemon* would work.
agent {
any {
}
}
options {
timeout(time: 120, unit: "MINUTES")
}
environment {
platform = 'aarch64-debian-stretch'
sm_ver = '60'
}
stages {
stage('Install latest qemu binaries') {
steps {
sh( script: update_qemu )
}
}
stage('Pull latest docker image') {
steps {
sh "docker pull couchdbdev/arm64v8-debian-buster-erlang-20.3.8.24-1:latest"
}
}
stage('Build from tarball & test & packages') {
steps {
withDockerContainer(image: "couchdbdev/arm64v8-debian-buster-erlang-20.3.8.24-1:latest", args: "${DOCKER_ARGS}") {
unstash 'tarball'
withEnv(['MIX_HOME='+pwd(), 'HEX_HOME='+pwd()]) {
sh( script: build_and_test )
sh( script: make_packages )
sh( script: cleanup_and_save )
}
}
}
post {
always {
*/
// junit '**/.eunit/*.xml, **/_build/*/lib/couchdbtest/*.xml, **/src/mango/nosetests.xml, **/test/javascript/junit.xml'
/*
}
success {
archiveArtifacts artifacts: 'pkgs/**', fingerprint: true
}
}
}
} // stages
post {
cleanup {
sh 'rm -rf ${WORKSPACE}/*'
}
} // post
} // stage
*/
} // parallel
} // stage "Test and Package"
stage('Publish') {
when {
expression { return env.BRANCH_NAME ==~ /master|2.*.x|3.*.x|4.*.x|jenkins-.*/ }
}
agent {
docker {
image 'couchdbdev/debian-buster-erlang-20.3.8.24-1:latest'
label 'docker'
alwaysPull true
args "${DOCKER_ARGS}"
}
}
options {
skipDefaultCheckout()
timeout(time: 90, unit: "MINUTES")
}
steps {
withCredentials([sshUserPrivateKey(credentialsId: 'jenkins-key', keyFileVariable: 'KEY')]) {
sh 'rm -rf ${WORKSPACE}/*'
unstash 'tarball'
unarchive mapping: ['pkgs/' : '.']
echo 'Retrieving & cleaning current couchdb-vm2 tree...'
sh '''
rsync -avz -e "ssh -o StrictHostKeyChecking=no -i $KEY" jenkins@couchdb-vm2.apache.org:/var/www/html/$BRANCH_NAME . || mkdir -p $BRANCH_NAME
rm -rf $BRANCH_NAME/debian/* $BRANCH_NAME/el6/* $BRANCH_NAME/el7/* $BRANCH_NAME/el8/*
mkdir -p $BRANCH_NAME/debian $BRANCH_NAME/el6 $BRANCH_NAME/el7 $BRANCH_NAME/el8 $BRANCH_NAME/source
rsync -avz -e "ssh -o StrictHostKeyChecking=no -i $KEY" jenkins@couchdb-vm2.apache.org:/var/www/html/js .
'''
echo 'Building Debian repo...'
sh '''
git clone https://github.com/apache/couchdb-pkg
cp js/debian-stretch/*.deb pkgs/stretch
reprepro -b couchdb-pkg/repo includedeb stretch pkgs/stretch/*.deb
cp js/debian-buster/*.deb pkgs/stretch
reprepro -b couchdb-pkg/repo includedeb stretch pkgs/buster/*.deb
cp js/ubuntu-xenial/*.deb pkgs/xenial
reprepro -b couchdb-pkg/repo includedeb xenial pkgs/xenial/*.deb
cp js/ubuntu-bionic/*.deb pkgs/bionic
reprepro -b couchdb-pkg/repo includedeb bionic pkgs/bionic/*.deb
'''
echo 'Building CentOS repos...'
sh '''
cp js/centos-6/*rpm pkgs/centos6
cp js/centos-7/*rpm pkgs/centos7
cp js/centos-8/*rpm pkgs/centos8
cd pkgs/centos6 && createrepo --database .
cd ../centos7 && createrepo --database .
cd ../centos8 && createrepo --database .
'''
echo 'Building tree to upload...'
sh '''
mv couchdb-pkg/repo/pool $BRANCH_NAME/debian
mv couchdb-pkg/repo/dists $BRANCH_NAME/debian
mv pkgs/centos6/* $BRANCH_NAME/el6
mv pkgs/centos7/* $BRANCH_NAME/el7
mv pkgs/centos8/* $BRANCH_NAME/el8
mv apache-couchdb-*.tar.gz $BRANCH_NAME/source
cd $BRANCH_NAME/source
ls -1tr | head -n -10 | xargs -d '\n' rm -f --
cd ../..
'''
echo 'rsyncing tree to couchdb-vm2...'
sh '''
rsync -avz --delete -e "ssh -o StrictHostKeyChecking=no -i $KEY" $BRANCH_NAME jenkins@couchdb-vm2.apache.org:/var/www/html
rm -rf $BRANCH_NAME couchdb-pkg *.tar.gz
'''
} // withCredentials
} // steps
} // stage
} // stages
post {
success {
mail to: "${env.recipient}",
replyTo: "${env.recipient}",
subject: "[Jenkins] SUCCESS: ${currentBuild.fullDisplayName}",
body: "Yay, we passed. ${env.RUN_DISPLAY_URL}"
}
unstable {
mail to: "${env.recipient}",
replyTo: "${env.recipient}",
subject: "[Jenkins] SUCCESS: ${currentBuild.fullDisplayName}",
body: "Eep! Build is unstable... ${env.RUN_DISPLAY_URL}"
}
failure {
mail to: "${env.recipient}",
replyTo: "${env.recipient}",
subject: "[Jenkins] FAILURE: ${currentBuild.fullDisplayName}",
body: "Boo, we failed. ${env.RUN_DISPLAY_URL}"
}
}
} // pipeline
|