-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathJenkinsfile
723 lines (640 loc) · 37.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
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
// Jenkinsfile file for the production of STS/LTS delivery version with the jenkins job : "rainbow-cpaas/node-sdk-projects/Rainbow-Node-SDK"
@Library('rainbow-shared-library') _
//@Library('rainbow-shared-library@hubSearchIndex') _
import groovy.transform.Field
// Map with the default values
@Field
Map defaults = [
build: 'nodesdk', // Which SDK documentation will be build
nextVersion: '0.0.0', // Debian package version. It's a 3 digits numbers.
stash: 'doc'
]
def DOC_PATH = ''
enum RELEASENAMEENUM {
STS,
LTS,
sts,
lts
} // Enum of possible release name values.
def getReleaseName(upper) {
println "getReleaseName - upper : " + upper;
if ( "${env.BRANCH_NAME}" == "STSDelivery" && upper) {
// echo "getReleaseName() will return STS"
return "STS";
}
if ( "${env.BRANCH_NAME}" == "STSDelivery" && !upper) {
//echo "getReleaseName() will return sts"
return "sts";
}
if ( "${env.BRANCH_NAME}" == "LTSDelivery" && upper) {
//echo "getReleaseName() will return LTS"
return "LTS";
}
if ( "${env.BRANCH_NAME}" == "LTSDelivery" && !upper) {
//echo "getReleaseName() will return lts"
return "lts";
}
}
pipeline {
agent {
label {
label "docker-slave-cpaas-bullseye"
customWorkspace "/home/jenkins/workspace/SDK-Node-SDK-${env.BRANCH_NAME}"
}
}
options {
timeout(time: 1, unit: 'HOURS')
disableConcurrentBuilds()
//withCredentials()
buildDiscarder(logRotator(
numToKeepStr: '30',
artifactNumToKeepStr: '30'
))
}
parameters {
string(name: 'RAINBOWNODESDKVERSION', defaultValue: '2.0.0-lts.0', description: 'What is the version of the STS/LTS SDK to build?')
booleanParam(name: 'SENDEMAIL', defaultValue: false, description: 'Send email after of the STS/LTS SDK built?')
booleanParam(name: 'SENDEMAILTOVBERDER', defaultValue: false, description: 'Send email after of the lts SDK built to [email protected] only ?')
booleanParam(name: 'DEBUGINTERNAL', defaultValue: true, description: 'Should this STS/LTS version be compiled with internal debug ?')
booleanParam(name: 'LTSBETA', defaultValue: false, description: 'Should this STS version be also an LTS BETA Version ?')
booleanParam(name: 'PUBLISHONNPMJSWITHSTSTAG', defaultValue: false, description: 'Publish this STS/LTS version to npmjs with the tag \"sts\" else with \".net\" tag ?')
booleanParam(name: 'PUBLISHTONPMANDSETTAGINGIT', defaultValue: true, description: 'Publish the sts SDK/LTS built to npmjs and save the tag/branch to GIT.')
//string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?')
//text(name: 'BIOGRAPHY', defaultValue: '', description: 'Enter some information about the person')
//booleanParam(name: 'TOGGLE', defaultValue: true, description: 'Toggle this value')
//choice(name: 'CHOICE', choices: ['One', 'Two', 'Three'], description: 'Pick something')
//password(name: 'PASSWORD', defaultValue: 'SECRET', description: 'Enter a password')
}
environment {
RELEASENAMEUPPERNAME = getReleaseName(true) // 'Name of the release in UPPPERCASE.')
RELEASENAMELOWERNAME = getReleaseName(false) // 'Name of the release in LOWERCASE.')
MJAPIKEY = credentials('2f8c39d0-35d5-4b67-a68a-f60aaa7084ad') // 6f119214480245deed79c5a45c59bae6/****** (MailJet API Key to post emails)
NPMJSAUTH = credentials('6ba55a5f-c0fa-41c3-b5dd-0c0f62ee22b5') // npmjs /****** (npmjs auth token to publish vberder)
GITLABVBERDER = credentials('b04ca5f5-3666-431d-aaf4-c6c239121510') // gitlab credential of vincent berder.
VBERDERRB = credentials('5bf46f68-1d87-4091-9aba-c337198503c8') // (vberder - OFFICIAL).
APP = credentials('25181a6c-2586-477d-9b95-0a1cc456c831') // (Rainbow Official Vberder AppId).
}
stages {
stage('Init') {
when {
anyOf {
allOf {
branch "STSDelivery";
}
allOf {
branch "LTSDelivery";
}
}
}
steps {
script {
BUILD_TRIGGER_BY = currentBuild.getBuildCauses()[0].shortDescription + " / " + currentBuild.getBuildCauses()[1].shortDescription
//BUILD_TRIGGER_BY = currentBuild.getBuildCauses()[0]
//BUILD_TRIGGER_BY = currentBuild.getBuildCauses()
CAUSE = currentBuild.getBuildCauses('hudson.model.Cause$UserIdCause')
}
echo "BUILD_TRIGGER_BY : ${BUILD_TRIGGER_BY}"
echo "userName: ${CAUSE.userName}"
}
}
stage('Show for parameters') {
//input {
// message "parameters?"
// ok "Yes, we should."
// parameters {
// string(name: 'RAINBOWNODESDKVERSION', defaultValue: '1.87.0', description: 'What is the version of the STS SDK to build?')
// booleanParam(name: 'SENDEMAIL', defaultValue: false, description: 'Send email after of the STS SDK built?')
// }
//}
when {
anyOf {
allOf {
branch "STSDelivery";
}
allOf {
branch "LTSDelivery";
}
}
}
/*when {
anyOf {
allOf {
branch "STSDelivery";
triggeredBy 'user'
}
allOf {
branch "LTSDelivery";
triggeredBy 'user'
}
allOf {
branch "STSDelivery";
triggeredBy cause: 'UserIdCause'
}
allOf {
branch "LTSDelivery";
triggeredBy cause: 'UserIdCause'
}
allOf {
branch "STSDelivery";
triggeredBy 'SCMTrigger'
}
allOf {
branch "LTSDelivery";
triggeredBy 'SCMTrigger'
}
allOf {
branch "STSDelivery";
triggeredBy 'SCM'
}
allOf {
branch "LTSDelivery";
triggeredBy 'SCM'
}
allOf {
branch "STSDelivery";
triggeredBy 'UpstreamCause'
}
allOf {
branch "LTSDelivery";
triggeredBy 'UpstreamCause'
}
allOf {
branch "STSDelivery";
triggeredBy 'TimerTrigger'
}
allOf {
branch "LTSDelivery";
triggeredBy 'TimerTrigger'
}
allOf {
branch "STSDelivery";
triggeredBy 'BuildUpstreamCause'
}
allOf {
branch "LTSDelivery";
triggeredBy 'BuildUpstreamCause'
}
}
} // */
steps {
echo "Parameters to build from branch ${env.BRANCH_NAME} : "
echo "Rainbow-Node-SDK : ${params.RAINBOWNODESDKVERSION}"
echo "SENDEMAIL : ${params.SENDEMAIL}"
echo "SENDEMAILTOVBERDER : ${params.SENDEMAILTOVBERDER}"
echo "DEBUGINTERNAL : ${params.DEBUGINTERNAL}"
echo "LTSBETA : ${params.LTSBETA} "
echo "PUBLISHONNPMJSWITHSTSTAG : ${params.PUBLISHONNPMJSWITHSTSTAG} "
echo "PUBLISHTONPMANDSETTAGINGIT : ${params.PUBLISHTONPMANDSETTAGINGIT} "
echo "Environment variables to build from branch ${env.BRANCH_NAME} : "
echo "RELEASENAMEUPPERNAME : ${env.RELEASENAMEUPPERNAME}"
echo "RELEASENAMELOWERNAME : ${env.RELEASENAMELOWERNAME}"
sh 'echo "Service user is $MJAPIKEY_USR , password is $MJAPIKEY_PSW"'
sh script: """
if [ "${RELEASENAMELOWERNAME}" = "${RELEASENAMEENUM.sts}" ]; then
echo "Lower Release Name is ${RELEASENAMEENUM.sts}"
fi
if [ "${RELEASENAMEUPPERNAME}" = "${RELEASENAMEENUM.STS}" ]; then
echo "Upper Release Name is ${RELEASENAMEENUM.STS}"
fi
if [ "${RELEASENAMELOWERNAME}" = "${RELEASENAMEENUM.lts}" ]; then
echo "Lower Release Name is ${RELEASENAMEENUM.lts}"
fi
if [ "${RELEASENAMEUPPERNAME}" = "${RELEASENAMEENUM.LTS}" ]; then
echo "Upper Release Name is ${RELEASENAMEENUM.LTS}"
fi
"""
}
}
stage('Checkout') {
when {
anyOf {
allOf {
branch "STSDelivery";
triggeredBy 'user'
}
allOf {
branch "LTSDelivery";
triggeredBy 'user'
}
}
}
steps{
echo "Clean ${env.workspace} customWorkspace before build"
cleanWs()
echo "Branch is ${env.BRANCH_NAME}..."
checkout scm
//echo "Stash files used to describe debian package and lts_version.json"
//stash includes: "Documentation/debian/**, Documentation/lts_version.json", name: "debianFilesDescriptor"
}
}
/*
stage('Check Build Cause'){
when {
allOf {
branch "STSDelivery";
triggeredBy 'user'
}
}
steps{
script{
// get Build Causes
// https://stackoverflow.com/questions/43597803/how-to-differentiate-build-triggers-in-jenkins-pipeline
echo "full cause : ${currentBuild.getBuildCauses()}" //Always returns full Cause
echo "branch events : ${currentBuild.getBuildCauses('jenkins.branch.BranchEventCause')}" // Only returns for branch events
echo "SCM trigger : ${currentBuild.getBuildCauses('hudson.triggers.SCMTrigger$SCMTriggerCause')}" // Only returns SCM Trigger
echo "User initiate : ${currentBuild.getBuildCauses('hudson.model.Cause$UserIdCause')}" // Only returns if user initiates via Jenkins GUI
def GitPushCause = currentBuild.getBuildCauses('jenkins.branch.BranchEventCause')
def IndexingCause = currentBuild.getBuildCauses('jenkins.branch.BranchIndexingCause')
def UserCause = currentBuild.getBuildCauses('hudson.model.Cause$UserIdCause')
// If a cause was populated do...
if (GitPushCause) {
println "********* Git Push *********"
println GitPushCause.getShortDescription()
stage ('Stage 1') {
sh 'echo Stage 1'
}
} else if (UserCause) {
println "******* Manual Build Detected *******"
println "UserCause : " + UserCause.getShortDescription()
stage ('Stage 2') {
sh 'echo Stage 2'
}
} else if (IndexingCause) {
println "******* IndexingCause Build Detected *******"
println "IndexingCause : " + IndexingCause
stage ('Stage 3') {
sh 'echo Stage 3'
}
}else {
println "unknown cause"
}
}
}
}
// */
stage('WhenJenkinsfileChanged') {
when {
anyOf {
allOf {
branch "STSDelivery";
//triggeredBy 'UpstreamCause'
//triggeredBy "[[_class:jenkins.branch.BranchIndexingCause, shortDescription:Branch indexing]]"
triggeredBy cause: 'BranchIndexingCause' , detail: "Branch indexing"// cause($class: 'jenkins.branch.BranchIndexingCause')
//triggeredBy cause : 'jenkins.branch.BranchIndexingCause' // cause($class: 'jenkins.branch.BranchIndexingCause')
}
allOf {
branch "LTSDelivery";
//triggeredBy 'UpstreamCause'
//triggeredBy "[[_class:jenkins.branch.BranchIndexingCause, shortDescription:Branch indexing]]"
triggeredBy cause: 'BranchIndexingCause' , detail: "Branch indexing"// cause($class: 'jenkins.branch.BranchIndexingCause')
//triggeredBy cause : 'jenkins.branch.BranchIndexingCause' // cause($class: 'jenkins.branch.BranchIndexingCause')
}
}
}
steps{
echo "WhenJenkinsfileChanged build"
/*
echo "Clean ${env.workspace} customWorkspace before build"
cleanWs()
echo "Branch is ${env.BRANCH_NAME}..."
checkout scm
// */
// Get all Causes for the current build
//causes = currentBuild.getBuildCauses()
//def causes = currentBuild.getBuildCauses()
// Get a specific Cause type (in this case the user who kicked off the build),
// if present.
//specificCause = currentBuild.getBuildCauses('hudson.model.Cause$UserIdCause')
//def specificCause = currentBuild.getBuildCauses('hudson.model.Cause$UserIdCause')
//echo "WhenJenkinsfileChanged causes : ${causes}, specificCause : ${specificCause}"
sh script: """
#echo "registry=https://10.10.13.10:4873/
#//10.10.13.10:4873/:_authToken=\"bqyuhm71xMxSA8+6hA3rdg==\"" >> ~/.npmrc
echo ---------- Set the NPM config and install node stable version :
#mkdir ${WORKSPACE}/.npm-packages
#npm config set prefix "${WORKSPACE}/.npm-packages"
#export PATH=${WORKSPACE}/.npm-packages/bin:${PATH}
#more ~/.npmrc > ~/.npmrc.sav
#echo "# UPDATE FROM JENKINS JOBS." > ~/.npmrc
#echo "registry=https://registry.npmjs.org/
#//registry.npmjs.org/:_authToken=${NPMJSAUTH_PSW}" |tee ./.npmrc
##sudo npm install npm -g
#sudo npm install n -g
#sudo n stable
##npm install -g https://tls-test.npmjs.com/tls-test-1.0.0.tgz
#npm install https://tls-test.npmjs.com/tls-test-1.0.0.tgz
#more ~/.npmrc.sav > ~/.npmrc
"""
}
}
stage('Build') {
when {
anyOf {
allOf {
branch "STSDelivery";
triggeredBy 'user'
}
allOf {
branch "LTSDelivery";
triggeredBy 'user'
}
}
}
steps{
echo "Build the sources and doc files of the Rainbow-Node-SDK."
//echo "DOC_PATH: /${DOC_PATH}"
// credentialsId here is the credentials you have set up in Jenkins for pushing to that repository using username and password.
//withCredentials([usernamePassword(credentialsId: 'b04ca5f5-3666-431d-aaf4-c6c239121510', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
//sshagent(['b04ca5f5-3666-431d-aaf4-c6c239121510']) {
// git url: "ssh://[email protected]:22/cloud-services/Rainbow-Node-SDK",
//git url: "https://git.openrainbow.org/cloud-services/Rainbow-Node-SDK",
// git url: "https://git.openrainbow.org",
// credentialsId: 'b04ca5f5-3666-431d-aaf4-c6c239121510',
// branch: "*"
// branch: "${env.BRANCH_NAME}"
sh script: """
#echo "Build's shell the Rainbow-Node-SDK : ${RAINBOWNODESDKVERSION} with send email : ${SENDEMAIL} and is LTSBETA : ${LTSBETA}"
echo ---------- Set the GIT config to be able to upload to server :
git config --local credential.helper "!f() { echo username=\\$GITLABVBERDER_USR; echo password=\\$GITLABVBERDER_PSW; }; f"
git config --global user.email "[email protected]"
git config --global user.name "[email protected]"
#echo ---------- Create a specific branch :
#git branch "delivered${RAINBOWNODESDKVERSION}"
#git checkout "delivered${RAINBOWNODESDKVERSION}"
#git push --set-upstream origin "delivered${RAINBOWNODESDKVERSION}"
if [ "${RELEASENAMEUPPERNAME}" = "${RELEASENAMEENUM.LTS}" ]; then
${PUBLISHTONPMANDSETTAGINGIT} && git branch "delivered${RAINBOWNODESDKVERSION}"
${PUBLISHTONPMANDSETTAGINGIT} && git checkout "delivered${RAINBOWNODESDKVERSION}"
${PUBLISHTONPMANDSETTAGINGIT} && git push --set-upstream origin "delivered${RAINBOWNODESDKVERSION}"
fi
#echo "registry=https://10.10.13.10:4873/
#//10.10.13.10:4873/:_authToken=\"bqyuhm71xMxSA8+6hA3rdg==\"" >> ~/.npmrc
echo ---------- Set the NPM config and install node stable version :
mkdir ${WORKSPACE}/.npm-packages
npm config set prefix "${WORKSPACE}/.npm-packages"
export PATH=${WORKSPACE}/.npm-packages/bin:${PATH}
more ~/.npmrc > ~/.npmrc.sav
echo "# UPDATE FROM JENKINS JOBS." > ~/.npmrc
echo "registry=https://registry.npmjs.org/
//registry.npmjs.org/:_authToken=${NPMJSAUTH_PSW}" |tee ./.npmrc
#sudo npm install npm -g
sudo npm install n -g
sudo n stable
sudo npm install --global npm@6
cd ${WORKSPACE}
echo ---------- STEP install the library :
npm install
ls
ls ./src/**/*
npm version "${RAINBOWNODESDKVERSION}" --allow-same-version
if [ "${DEBUGINTERNAL}" = "true" ]; then
echo "Build sources with Internal DEBUG activated."
echo ---------- STEP grunt :
# test of grunt specifics tasks :
#grunt ts --verbose
#grunt dtsGenerator --verbose
#echo Sub Step 1 : To compil the sources
grunt debugDeliveryBuild --verbose
#echo Sub Step 2 : To prepare the sources + doc for package
grunt debugDeliveryDelivery --verbose
else
echo "Build sources with Internal DEBUG removed."
echo ---------- STEP grunt :
echo Sub Step 1 : To compil the sources
grunt --verbose
echo Sub Step 2 : To prepare the sources + doc for package
grunt delivery --verbose
fi
#echo ---------- STEP commit :
if [ "${PUBLISHTONPMANDSETTAGINGIT}" = "true" ]; then
git reset --hard "origin/delivered${RAINBOWNODESDKVERSION}"
else
git reset --hard "origin/${env.BRANCH_NAME}"
fi
npm version "${RAINBOWNODESDKVERSION}" --allow-same-version
echo ---------- STEP whoami :
npm whoami
#npm view
npm token list
echo ---------- Generate the Cyclone DX file :
node ./node_modules/@cyclonedx/cyclonedx-npm/bin/cyclonedx-npm-cli.js --ignore-npm-errors --output-file build/rainbownodesdk.cdx
cp -R build/JSONDOCS guide/JSONDOCS
echo ---------- STEP publish :
if [ "${PUBLISHTONPMANDSETTAGINGIT}" = "true" ]; then
if [ "${RELEASENAMEUPPERNAME}" = "${RELEASENAMEENUM.LTS}" ]; then
${PUBLISHTONPMANDSETTAGINGIT} && npm publish
fi
if [ "${RELEASENAMEUPPERNAME}" = "${RELEASENAMEENUM.STS}" ]; then
if [ "${PUBLISHONNPMJSWITHSTSTAG}" = "true" ]; then
echo "Publish on npmjs with tag."
npm publish --tag sts
else
echo "Publish on npmjs with node .net tag."
npm publish --tag .net
fi
fi
fi
echo ---------- PUSH tags AND files :
if [ "${RELEASENAMEUPPERNAME}" = "${RELEASENAMEENUM.STS}" ]; then
${PUBLISHTONPMANDSETTAGINGIT} && git tag -a ${RAINBOWNODESDKVERSION} -m "${RAINBOWNODESDKVERSION} is a ${RELEASENAMELOWERNAME} version."
${PUBLISHTONPMANDSETTAGINGIT} && git push origin HEAD:${env.BRANCH_NAME}
${PUBLISHTONPMANDSETTAGINGIT} && git push --tags origin HEAD:${env.BRANCH_NAME}
fi
if [ "${RELEASENAMEUPPERNAME}" = "${RELEASENAMEENUM.LTS}" ]; then
${PUBLISHTONPMANDSETTAGINGIT} && git tag -a ${RAINBOWNODESDKVERSION} -m "${RAINBOWNODESDKVERSION} is a ${RELEASENAMELOWERNAME} version."
${PUBLISHTONPMANDSETTAGINGIT} && git push origin "HEAD:delivered${RAINBOWNODESDKVERSION}"
${PUBLISHTONPMANDSETTAGINGIT} && git push --tags origin "HEAD:delivered${RAINBOWNODESDKVERSION}"
fi
echo ---------- send emails getDebianArtifacts parameters setted :
export MJ_APIKEY_PUBLIC="${MJAPIKEY_USR}"
export MJ_APIKEY_PRIVATE="${MJAPIKEY_PSW}"
if [ "${RELEASENAMEUPPERNAME}" = "${RELEASENAMEENUM.STS}" ]; then
${SENDEMAIL} && npm run-script sendmailPreProduction
${SENDEMAIL} && node mailing/postChangeLogInChannel.js host=official login=${VBERDERRB_USR} password=${VBERDERRB_PSW} appID=${APP_USR} appSecret=${APP_PSW}
# To send the mailing only to [email protected] .
${SENDEMAILTOVBERDER} && npm run-script sendmailProductionTest
${SENDEMAILTOVBERDER} && node mailing/postChangeLogInChannel.js host=official login=${VBERDERRB_USR} password=${VBERDERRB_PSW} appID=${APP_USR} appSecret=${APP_PSW} channelName=RNodeSdkChangeLog
fi
if [ "${RELEASENAMEUPPERNAME}" = "${RELEASENAMEENUM.LTS}" ]; then
${SENDEMAIL} && npm run-script sendmailProduction
${SENDEMAIL} && node mailing/postChangeLogInChannel.js host=official login=${VBERDERRB_USR} password=${VBERDERRB_PSW} appID=${APP_USR} appSecret=${APP_PSW}
# To send the mailing only to [email protected] .
${SENDEMAILTOVBERDER} && npm run-script sendmailProductionTest
fi
more ~/.npmrc.sav > ~/.npmrc
"""
}
}
stage('Build Documentation from Rainbow Node SDK') {
when {
anyOf {
allOf {
branch "STSDelivery";
triggeredBy 'user'
}
allOf {
branch "LTSDelivery";
triggeredBy 'user'
}
}
}
steps{
sh script: """
echo "Build Documentation from Makefile"
make all${RELEASENAMELOWERNAME}
if [ "${RELEASENAMEUPPERNAME}" = "${RELEASENAMEENUM.STS}" ]; then
echo "{
\\"lts\\": false,
\\"ltsbeta\\": ${LTSBETA},
\\"sts\\": true
}" > ./doc/sdk/node/${RELEASENAMELOWERNAME}/version.json
fi
if [ "${RELEASENAMEUPPERNAME}" = "${RELEASENAMEENUM.LTS}" ]; then
echo "{
\\"lts\\": true,
\\"ltsbeta\\": false,
\\"sts\\": false
}" > ./doc/sdk/node/${RELEASENAMELOWERNAME}/version.json
fi
"""
//stash includes: 'doc/sdk/node/**/*.*, doc/sdk/node/index.yml, doc/sdk/node/sitemap.yml', name: 'docfiles'
}
}
stage('Documentation Packaging') {
when {
anyOf {
allOf {
branch "STSDelivery";
triggeredBy 'user'
}
allOf {
branch "LTSDelivery";
triggeredBy 'user'
}
}
}
steps {
script {
// node('docker-slave-nodebackend-buster-12.x') {
stage('Build Debian Folder') {
try {
echo "Build debian pkg ${params.RAINBOWNODESDKVERSION} ${workspace}"
sh script: """
echo "copy Docs and Debian config files to the folder Documentation ."
cd "${workspace}"
echo find debian in workspace
find debian
mkdir -p Documentation
cp -R doc debian Documentation/
echo "update files with doc/sdk/node path which should be doc/sdk/node/${RELEASENAMELOWERNAME} into the folder Documentation ."
sed "s/otlite-sdk-node-doc/otlite-sdk-node-doc-${RELEASENAMELOWERNAME}/" debian/control |tee "${workspace}/Documentation/debian/control"
sed "s/\\/usr\\/share\\/sdkdoc\\/node\\/sitemap.xml/\\/usr\\/share\\/sdkdoc\\/node\\/${RELEASENAMELOWERNAME}\\/sitemap.xml/" debian/postinst |tee "${workspace}/Documentation/debian/postinst"
# more Documentation/debian/control
sed "s/\\/doc\\/sdk\\/node\\//\\/doc\\/sdk\\/node\\/${RELEASENAMELOWERNAME}\\//g" "guide/RainbowNodeSDKNews.md" |tee "Documentation/doc/sdk/node/${RELEASENAMELOWERNAME}/guides/RainbowNodeSDKNews.md"
# more Documentation/doc/sdk/node/${RELEASENAMELOWERNAME}/guides/RainbowNodeSDKNews.md
sed "s/\\/doc\\/sdk\\/node\\//\\/doc\\/sdk\\/node\\/${RELEASENAMELOWERNAME}\\//g" "guide/Answering_chat_message.md" |tee "Documentation/doc/sdk/node/${RELEASENAMELOWERNAME}/guides/Answering_chat_message.md"
sed "s/\\/doc\\/sdk\\/node\\//\\/doc\\/sdk\\/node\\/${RELEASENAMELOWERNAME}\\//g" "guide/Connecting_to_Rainbow_S2S_Mode.md" |tee "Documentation/doc/sdk/node/${RELEASENAMELOWERNAME}/guides/Connecting_to_Rainbow_S2S_Mode.md"
sed "s/\\/doc\\/sdk\\/node\\//\\/doc\\/sdk\\/node\\/${RELEASENAMELOWERNAME}\\//g" "guide/Connecting_to_Rainbow_XMPP_Mode.md" |tee "Documentation/doc/sdk/node/${RELEASENAMELOWERNAME}/guides/Connecting_to_Rainbow_XMPP_Mode.md"
sed "s/\\/doc\\/sdk\\/node\\//\\/doc\\/sdk\\/node\\/${RELEASENAMELOWERNAME}\\//g" "guide/Development_Kit.md" |tee "Documentation/doc/sdk/node/${RELEASENAMELOWERNAME}/guides/Development_Kit.md"
sed "s/\\/doc\\/sdk\\/node\\//\\/doc\\/sdk\\/node\\/${RELEASENAMELOWERNAME}\\//g" "guide/Getting_Started.md" |tee "Documentation/doc/sdk/node/${RELEASENAMELOWERNAME}/guides/Getting_Started.md"
sed "s/\\/doc\\/sdk\\/node\\//\\/doc\\/sdk\\/node\\/${RELEASENAMELOWERNAME}\\//g" "guide/Legals.md" |tee "Documentation/doc/sdk/node/${RELEASENAMELOWERNAME}/guides/Legals.md"
sed "s/\\/doc\\/sdk\\/node\\//\\/doc\\/sdk\\/node\\/${RELEASENAMELOWERNAME}\\//g" "guide/Managing_bubbles.md" |tee "Documentation/doc/sdk/node/${RELEASENAMELOWERNAME}/guides/Managing_bubbles.md"
sed "s/\\/doc\\/sdk\\/node\\//\\/doc\\/sdk\\/node\\/${RELEASENAMELOWERNAME}\\//g" "guide/Managing_conferences.md" |tee "Documentation/doc/sdk/node/${RELEASENAMELOWERNAME}/guides/Managing_conferences.md"
sed "s/\\/doc\\/sdk\\/node\\//\\/doc\\/sdk\\/node\\/${RELEASENAMELOWERNAME}\\//g" "guide/Managing_RPCoverXMPP.md" |tee "Documentation/doc/sdk/node/${RELEASENAMELOWERNAME}/guides/Managing_RPCoverXMPP.md"
sed "s/\\/doc\\/sdk\\/node\\//\\/doc\\/sdk\\/node\\/${RELEASENAMELOWERNAME}\\//g" "build/What_is_new_generated.md" |tee "Documentation/doc/sdk/node/${RELEASENAMELOWERNAME}/guides/What_is_new.md"
sed "s/ref:doc\\/sdk\\/node\\//ref:doc\\/sdk\\/node\\/${RELEASENAMELOWERNAME}\\//g" "index.yml" |tee "Documentation/doc/sdk/node/${RELEASENAMELOWERNAME}/index.yml"
sed "s/\\/doc\\/sdk\\/node\\//\\/doc\\/sdk\\/node\\/${RELEASENAMELOWERNAME}\\//g" "sitemap.xml" |tee "Documentation/doc/sdk/node/${RELEASENAMELOWERNAME}/sitemap.xml"
"""
stash includes: 'Documentation/**', name: 'DocumentationFolder'
} catch (Exception e) {
echo "Failure: ${currentBuild.result}: ${e}"
}
}
stage("Generate documentation search index") {
try {
echo "Build Hub V2 search index : "
// unstash 'DocumentationFolder'
sh script: """
# echo "folder where run the Build Hub V2 search index."
# pwd
# ls
"""
// unstash "withBuildDir"
echo "Installation of developers_searchindex HUB V2 search library."
sh """
cd "${workspace}/Documentation"
npm install developers_searchindex --registry https://nexus.openrainbow.io/repository/npm-dev
npm list developers_searchindex
"""
echo "build hub doc"
sh script: """
# cd "${workspace}/Documentation"
sudo npm install npm -g
npm exec -- developers_searchindex --docPath Documentation/doc/sdk/node/${RELEASENAMELOWERNAME}
# sh "npx developers_searchindex --docPath build/doc/hub"
# ls -la build/doc/hub
"""
// generateHubV2DocumentationSearchIndex("Documentation/doc/sdk/node/${RELEASENAMELOWERNAME}", "DocumentationFolder")
} catch (Exception e) {
echo "Failure: ${currentBuild.result}: ${e}"
}
}
stage('Build Debian package') {
try {
echo "Build debian the package : "
sh script: """
#find Documentation/
#cd "${workspace}/Documentation"
# apt-key adv --keyserver dl.google.com/linux/chrome/deb --recv-keys E88979FB9B30ACF2 2> /dev/null
# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 78BD65473CB3BD13 2> /dev/null
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E88979FB9B30ACF2
"""
debianBuild(
debianPath: 'Documentation',
nextVersion: "${params.RAINBOWNODESDKVERSION}" ,
language: 'other'
)
} catch (Exception e) {
echo "Failure: ${currentBuild.result}: ${e}"
}
finally {
// notifyBuild(currentBuild.result)
}
}
stage('Debian Publish') {
try {
echo "Publish Debian package : "
echo debianPublish.getDebianArtifacts().join('\n')
debianPublish(
repository: 'nightly-non-free-bullseye',
stashName: "deb"
)
} catch (Exception e) {
echo "Failure: ${currentBuild.result}: ${e}"
}
finally {
// notifyBuild(currentBuild.result)
}
}
}
}
}
}
post {
always {
sh 'echo "---- THE END ----"'
cleanWs(cleanWhenNotBuilt: false,
deleteDirs: true,
disableDeferredWipeout: true,
notFailBuild: true,
patterns: [[pattern: '.gitignore', type: 'INCLUDE'],
[pattern: '.propsfile', type: 'EXCLUDE']])
}
success {
sh 'echo "Build is OK" '
}
failure {
sh 'echo "Issue during build of the pipeline" '
}
}
}