forked from Marklogic-retired/marklogic-data-hub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
963 lines (945 loc) · 56.4 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
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
@Library('shared-libraries') _
import groovy.json.JsonSlurper
import groovy.json.JsonSlurperClassic
JIRA_ID="";
commitMessage="";
def prResponse="";
def prNumber;
def props;
githubAPIUrl="https://api.github.com/repos/marklogic/marklogic-data-hub"
def loadProperties() {
node {
checkout scm
properties = new Properties()
props.load(propertiesFile.newDataInputStream())
echo "Immediate one ${properties.repo}"
}
}
def dhflinuxTests(String mlVersion,String type){
script{
props = readProperties file:'data-hub/pipeline.properties';
copyRPM type,mlVersion
def dockerhost=setupMLDockerCluster 3
sh 'docker exec -u builder -i '+dockerhost+' /bin/sh -c "su -builder;export JAVA_HOME=`eval echo "$JAVA_HOME_DIR"`;export GRADLE_USER_HOME=$WORKSPACE$GRADLE_DIR;export M2_HOME=$MAVEN_HOME/bin;export PATH=$GRADLE_USER_HOME:$PATH:$MAVEN_HOME/bin;cd $WORKSPACE/data-hub;rm -rf $GRADLE_USER_HOME/caches;./gradlew clean;set +e;./gradlew marklogic-data-hub:test || true;sleep 10s;./gradlew ml-data-hub:test || true;sleep 10s;./gradlew web:test || true;sleep 10s;./gradlew marklogic-data-hub:testBootstrap || true;sleep 10s;./gradlew ml-data-hub:testFullCycle || true;"'
junit '**/TEST-*.xml'
commitMessage = sh (returnStdout: true, script:'''
curl -u $Credentials -X GET "'''+githubAPIUrl+'''/git/commits/${GIT_COMMIT}" ''')
def slurper = new JsonSlurperClassic().parseText(commitMessage.toString().trim())
def commit=slurper.message.toString().trim();
JIRA_ID=commit.split(("\\n"))[0].split(':')[0].trim();
JIRA_ID=JIRA_ID.split(" ")[0];
commitMessage=null;
//jiraAddComment comment: 'Jenkins rh7_cluster_9.0-Nightly Test Results For PR Available', idOrKey: JIRA_ID, site: 'JIRA'
}
}
def dhfqsLinuxTests(String mlVersion,String type){
script{
copyRPM type,mlVersion
setUpML '$WORKSPACE/xdmp/src/Mark*.rpm'
sh(script:'''#!/bin/bash
export JAVA_HOME=`eval echo "$JAVA_HOME_DIR"`;
export GRADLE_USER_HOME=$WORKSPACE$GRADLE_DIR;
export M2_HOME=$MAVEN_HOME/bin;
export PATH=$GRADLE_USER_HOME:$PATH:$MAVEN_HOME/bin;
cd $WORKSPACE/data-hub;
rm -rf $GRADLE_USER_HOME/caches;
./gradlew clean;
./gradlew build -x test;
nohup ./gradlew bootRun >> $WORKSPACE/bootRun.out &
sleep 60s;
nohup ./gradlew runUI >> $WORKSPACE/runUI.out &
sleep 120s;
cd web;
./node_modules/.bin/ng e2e --devServerTarget="" --suite all --base-url http://localhost:4200 || true;
''')
junit '**/web/e2e/reports/*.xml'
archiveArtifacts artifacts: 'data-hub/web/e2e/reports/*.html, data-hub/web/e2e/reports/*.xml, data-hub/web/e2e/reports/screenshots/*.png, data-hub/web/e2e/screenshoter-plugin/**/*, nohup.out'
commitMessage = sh (returnStdout: true, script:'''
curl -u $Credentials -X GET "'''+githubAPIUrl+'''/git/commits/${GIT_COMMIT}" ''')
def slurper = new JsonSlurperClassic().parseText(commitMessage.toString().trim())
def commit=slurper.message.toString().trim();
JIRA_ID=commit.split(("\\n"))[0].split(':')[0].trim();
JIRA_ID=JIRA_ID.split(" ")[0];
commitMessage=null;
//jiraAddComment comment: 'Jenkins qs_rh7_90-nightly Test Results For PR Available', idOrKey: JIRA_ID, site: 'JIRA'
}
}
def dhfWinTests(String mlVersion, String type){
script{
copyMSI type,mlVersion;
def pkgOutput=bat(returnStdout:true , script: '''
cd xdmp/src
for /f "delims=" %%a in ('dir /s /b *.msi') do set "name=%%~a"
echo %name%
''').trim().split();
def pkgLoc=pkgOutput[pkgOutput.size()-1]
gitCheckout 'ml-builds','https://github.com/marklogic/MarkLogic-Builds','master'
def bldOutput=bat(returnStdout:true , script: '''
cd ml-builds/scripts/lib/
CD
''').trim().split();
def bldPath=bldOutput[bldOutput.size()-1]
setupMLWinCluster bldPath,pkgLoc
bat 'cd data-hub & gradlew.bat clean'
bat 'cd data-hub & gradlew.bat marklogic-data-hub:test || exit /b 0'
bat 'cd data-hub & gradlew.bat ml-data-hub:test || exit /b 0'
bat 'cd data-hub & gradlew.bat web:test || exit /b 0'
junit '**/TEST-*.xml'
//jiraAddComment comment: 'Jenkins rh7_cluster_9.0-Nightly Test Results For PR Available', idOrKey: JIRA_ID, site: 'JIRA'
}
}
pipeline{
agent none;
options {
checkoutToSubdirectory 'data-hub'
skipStagesAfterUnstable()
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '30', numToKeepStr: '')
}
environment{
JAVA_HOME_DIR="~/java/jdk1.8.0_72"
GRADLE_DIR="/.gradle"
MAVEN_HOME="/usr/local/maven"
DMC_USER = credentials('MLBUILD_USER')
DMC_PASSWORD= credentials('MLBUILD_PASSWORD')
}
parameters{
string(name: 'Email', defaultValue: '[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]', description: 'Who should I say send the email to?')
}
stages{
stage('Pre-Build-Check'){
when {
changeRequest author: '', authorDisplayName: '', authorEmail: '', branch: '', fork: '', id: '', target: 'develop', title: '', url: ''
beforeAgent true
}
agent { label 'dhfLinuxAgent'}
steps{
script{
if(!env.CHANGE_TITLE.startsWith("DHFPROD-")){
sh 'exit 1'
}
def obj=new abortPrevBuilds();
obj.abortPrevBuilds();
}
}
post{
failure{
script{
def email;
if(env.CHANGE_AUTHOR){
def author=env.CHANGE_AUTHOR.toString().trim().toLowerCase()
email=getEmailFromGITUser author
}else{
email=Email
}
sendMail email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/${JOB_BASE_NAME}/${BUILD_ID} \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n Pipeline Failed as there is no JIRA ID. Please add JIRA ID to the PR Title',false,'NO JIRA ID for $BRANCH_NAME | pipeline Failed '
}
}
}
}
stage('Build-datahub'){
agent { label 'dhfLinuxAgent'}
steps{
script{
props = readProperties file:'data-hub/pipeline.properties';
if(env.CHANGE_TITLE){
JIRA_ID=env.CHANGE_TITLE.split(':')[0];
def transitionInput =[transition: [id: '41']]
//jiraTransitionIssue idOrKey: JIRA_ID, input: transitionInput, site: 'JIRA'
}
}
println(BRANCH_NAME)
sh 'export JAVA_HOME=`eval echo "$JAVA_HOME_DIR"`;export GRADLE_USER_HOME=$WORKSPACE$GRADLE_DIR;export M2_HOME=$MAVEN_HOME/bin;export PATH=$GRADLE_USER_HOME:$PATH:$MAVEN_HOME/bin;cd $WORKSPACE/data-hub;rm -rf $GRADLE_USER_HOME/caches;./gradlew clean --stacktrace;./gradlew build -x test;'
archiveArtifacts artifacts: 'data-hub/marklogic-data-hub/build/libs/* , data-hub/ml-data-hub-plugin/build/libs/* , data-hub/web/build/libs/*', onlyIfSuccessful: true }
post{
failure {
println("Datahub Build FAILED")
script{
def email;
if(env.CHANGE_AUTHOR){
def author=env.CHANGE_AUTHOR.toString().trim().toLowerCase()
email=getEmailFromGITUser author
}else{
email=Email
}
sendMail email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/${JOB_BASE_NAME}/${BUILD_ID} \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n Pipeline Failed at the stage while building datahub. Please fix the issues',false,'Data Hub Build for $BRANCH_NAME Failed'
}
}
}
}
stage('Unit-Tests'){
agent { label 'dhfLinuxAgent'}
steps{
script{
props = readProperties file:'data-hub/pipeline.properties';
copyRPM 'Release','10.0-3'
setUpML '$WORKSPACE/xdmp/src/Mark*.rpm'
sh 'export JAVA_HOME=`eval echo "$JAVA_HOME_DIR"`;export GRADLE_USER_HOME=$WORKSPACE$GRADLE_DIR;export M2_HOME=$MAVEN_HOME/bin;export PATH=$GRADLE_USER_HOME:$PATH:$MAVEN_HOME/bin;cd $WORKSPACE/data-hub;rm -rf $GRADLE_USER_HOME/caches;set +e;./gradlew clean;./gradlew marklogic-data-hub:test || true;sleep 10s;./gradlew ml-data-hub:test || true;./gradlew web:test || true;'
junit '**/TEST-*.xml'
if(env.CHANGE_TITLE){
JIRA_ID=env.CHANGE_TITLE.split(':')[0]
jiraAddComment comment: 'Jenkins Unit Test Results For PR Available', idOrKey: JIRA_ID, site: 'JIRA'
}
}
}
post{
always{
sh 'rm -rf $WORKSPACE/xdmp'
}
success {
println("Unit Tests Completed")
script{
def email;
if(env.CHANGE_AUTHOR){
def author=env.CHANGE_AUTHOR.toString().trim().toLowerCase()
email=getEmailFromGITUser author
}else{
email=Email
}
sendMail email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n All the Unit Tests Passed on $BRANCH_NAME and the next stage is Code-review.',false,'Unit Tests for $BRANCH_NAME Passed'
}
}
unstable {
println("Unit Tests Failed")
sh 'mkdir -p MLLogs;cp -r /var/opt/MarkLogic/Logs/* $WORKSPACE/MLLogs/'
archiveArtifacts artifacts: 'MLLogs/**/*'
script{
def email;
if(env.CHANGE_AUTHOR){
def author=env.CHANGE_AUTHOR.toString().trim().toLowerCase()
email=getEmailFromGITUser author
}else{
email=Email
}
sendMail email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n Some of the Unit Tests Failed on $BRANCH_NAME. Please look into the issues and fix it.',false,'Unit Tests for $BRANCH_NAME Failed'
}
}
}
}
stage('code-review'){
when {
allOf {
changeRequest author: '', authorDisplayName: '', authorEmail: '', branch: '', fork: '', id: '', target: '5.1-develop', title: '', url: ''
}
beforeAgent true
}
agent {label 'dhmaster'};
steps{
script{
props = readProperties file:'data-hub/pipeline.properties';
if(env.CHANGE_TITLE.split(':')[1].contains("Automated PR")){
println("Automated PR")
sh 'exit 0'
}else{
script{
props = readProperties file:'data-hub/pipeline.properties';
withCredentials([usernameColonPassword(credentialsId: '550650ab-ee92-4d31-a3f4-91a11d5388a3', variable: 'Credentials')]) {
def reviewersList = sh (returnStdout: true, script:'''
curl -u $Credentials -X GET '''+githubAPIUrl+'''/pulls/$CHANGE_ID/requested_reviewers
''')
def slurper = new JsonSlurperClassic().parseText(reviewersList.toString().trim())
def emailList="";
for(def user:slurper.users){
email=getEmailFromGITUser user.login;
emailList+=email+',';
}
sendMail emailList,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n $BRANCH_NAME is waiting for the code-review to complete. Please click on proceed button if all the reviewers approved the code here. \n\n ${BUILD_URL}input ',false,'Waiting for code review $BRANCH_NAME '
}
}
try{
timeout(time:60, unit:'MINUTES') {
input message:'Review Done?'
}
}catch(err){
currentBuild.result = "SUCCESS"
}
}
}
}
}
stage('PR'){
when {
changeRequest author: '', authorDisplayName: '', authorEmail: '', branch: '', fork: '', id: '', target: '5.1-develop', title: '', url: ''
beforeAgent true
}
agent {label 'dhmaster'};
steps{
retry(5){
withCredentials([usernameColonPassword(credentialsId: '550650ab-ee92-4d31-a3f4-91a11d5388a3', variable: 'Credentials')]) {
script{
props = readProperties file:'data-hub/pipeline.properties';
JIRA_ID=env.CHANGE_TITLE.split(':')[0]
def response = sh (returnStdout: true, script:'''curl -u $Credentials --header "application/vnd.github.merge-info-preview+json" "'''+githubAPIUrl+'''/pulls/$CHANGE_ID" | grep '"mergeable_state":' | cut -d ':' -f2 | cut -d ',' -f1 | tr -d '"' ''')
response=response.trim();
println(response)
if(response.equals("clean")){
println("merging can be done")
sh "curl -o - -s -w \"\n%{http_code}\n\" -X PUT -d '{\"commit_title\": \"$JIRA_ID: merging PR\", \"merge_method\": \"rebase\"}' -u $Credentials "+ githubAPIUrl+"/pulls/$CHANGE_ID/merge | tail -2 > mergeResult.txt"
def mergeResult = readFile('mergeResult.txt').trim()
if(mergeResult=="200"){
println("Merge successful")
}else{
println("Merge Failed")
sh 'exit 1'
}
}else if(response.equals("blocked")){
println("retry blocked");
withCredentials([usernameColonPassword(credentialsId: '550650ab-ee92-4d31-a3f4-91a11d5388a3', variable: 'Credentials')]) {
def reviewersList = sh (returnStdout: true, script:'''
curl -u $Credentials -X GET '''+githubAPIUrl+'''/pulls/$CHANGE_ID/requested_reviewers
''')
def slurper = new JsonSlurperClassic().parseText(reviewersList.toString().trim())
def emailList="";
for(def user:slurper.users){
email=getEmailFromGITUser user.login;
emailList+=email+',';
}
sendMail emailList,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n $BRANCH_NAME is waiting for the code-review to complete. Please click on proceed button if all the reviewers approved the code here. \n\n ${BUILD_URL}input ',false,'Waiting for code review $BRANCH_NAME '
}
sleep time: 30, unit: 'MINUTES'
throw new Exception("Waiting for all the status checks to pass");
}else if(response.equals("unstable")){
println("retry unstable")
sh "curl -o - -s -w \"\n%{http_code}\n\" -X PUT -d '{\"commit_title\": \"$JIRA_ID: merging PR\", \"merge_method\": \"rebase\"}' -u $Credentials "+githubAPIUrl+"/pulls/$CHANGE_ID/merge | tail -2 > mergeResult.txt"
def mergeResult = readFile('mergeResult.txt').trim()
if(mergeResult=="200"){
println("Merge successful")
}else{
println("Merge Failed")
sh 'exit 1'
}
println("Result is"+ mergeResult)
}else{
println("merging not possible")
currentBuild.result = "FAILURE"
sh 'exit 1';
}
}
}
}
}
post{
success {
println("Merge Successful")
script{
def author=env.CHANGE_AUTHOR.toString().trim().toLowerCase()
def email=getEmailFromGITUser author
sendMail email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n $BRANCH_NAME is merged and it will run the end to end tests in the next stage',false,' $BRANCH_NAME is Merged'
}
}
failure {
println("Retried 5times")
script{
def author=env.CHANGE_AUTHOR.toString().trim().toLowerCase()
def email=getEmailFromGITUser author
sendMail email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n $BRANCH_NAME is not merged into the target branch. Please check the merge status of the PR if there are any merge conflicts or if the code is not reviewed. \n\n Click on the link Restart PR below to retry merge if the merge state is clean i.e., Code is reviewed and there are no merge conflicts with the target branch. \n\n ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID',false,' $BRANCH_NAME Cannot be Merged'
}
}
}
}
stage('rh7-singlenode'){
when {
expression{
props = readProperties file:'data-hub/pipeline.properties';
println(props['ExecutionBranch'])
return (env.BRANCH_NAME==props['ExecutionBranch'])
}
}
agent { label 'dhfLinuxAgent'}
steps{
script{
props = readProperties file:'data-hub/pipeline.properties';
copyRPM 'Release','9.0-12'
setUpML '$WORKSPACE/xdmp/src/Mark*.rpm'
sh 'export JAVA_HOME=`eval echo "$JAVA_HOME_DIR"`;export GRADLE_USER_HOME=$WORKSPACE$GRADLE_DIR;export M2_HOME=$MAVEN_HOME/bin;export PATH=$GRADLE_USER_HOME:$PATH:$MAVEN_HOME/bin;cd $WORKSPACE/data-hub;rm -rf $GRADLE_USER_HOME/caches;./gradlew clean;set +e;./gradlew marklogic-data-hub:test -Dorg.gradle.jvmargs=-Xmx1g || true;sleep 10s;./gradlew ml-data-hub:test || true;sleep 10s;./gradlew web:test || true;sleep 10s;./gradlew marklogic-data-hub:testBootstrap || true;sleep 10s;./gradlew ml-data-hub:testFullCycle || true;'
junit '**/TEST-*.xml'
commitMessage = sh (returnStdout: true, script:'''
curl -u $Credentials -X GET "'''+githubAPIUrl+'''/git/commits/${GIT_COMMIT}" ''')
def slurper = new JsonSlurperClassic().parseText(commitMessage.toString().trim())
def commit=slurper.message.toString().trim();
JIRA_ID=commit.split(("\\n"))[0].split(':')[0].trim();
JIRA_ID=JIRA_ID.split(" ")[0];
commitMessage=null;
//jiraAddComment comment: 'Jenkins rh7-singlenode Test Results For PR Available', idOrKey: JIRA_ID, site: 'JIRA'
}
}
post{
always{
sh 'rm -rf $WORKSPACE/xdmp'
}
success {
println("End-End Tests Completed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n All the End to End tests of the branch $BRANCH_NAME passed and the next stage is to run all the end-end tests on multiple platforms in parallel',false,'rh7-singlenode Tests for $BRANCH_NAME Passed'
}
unstable {
println("End-End Tests Failed")
sh 'mkdir -p MLLogs;cp -r /var/opt/MarkLogic/Logs/* $WORKSPACE/MLLogs/'
archiveArtifacts artifacts: 'MLLogs/**/*'
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n Some of the End to End tests of the branch $BRANCH_NAME failed. Please fix the tests and create a PR or create a bug for the failures.',false,'rh7-singlenode Tests for $BRANCH_NAME Failed'
}
}
}
stage('Linux Core Parallel Execution'){
when {
expression{
node('dhmaster'){
props = readProperties file:'data-hub/pipeline.properties';
println(props['ExecutionBranch'])
return (env.BRANCH_NAME==props['ExecutionBranch'])
}
}
}
parallel{
stage('rh7_cluster_10.0-Nightly'){
agent { label 'dhfLinuxAgent'}
steps{
dhflinuxTests("10.0","Latest")
}
post{
always{
sh 'rm -rf $WORKSPACE/xdmp'
}
success {
println("rh7_cluster_10.0-Nightly Tests Completed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n All the End to End tests on rh7 cluster 10.0-Nightly of the branch $BRANCH_NAME passed and the next stage is to merge it to release branch if all the end-end tests pass',false,'rh7_cluster_10.0-Nightly Tests $BRANCH_NAME Passed'
// sh './gradlew publish'
}
unstable {
println("rh7_cluster_10.0-Nightly Tests Failed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n Some of the End to End tests of the branch $BRANCH_NAME on 10.0-Nightly rh7 cluster failed. Please fix the tests and create a PR or create a bug for the failures.',false,'rh7_cluster_10.0-Nightly Tests for $BRANCH_NAME Failed'
}
}
}
stage('rh7_cluster_9.0-Nightly'){
agent { label 'dhfLinuxAgent'}
steps{
dhflinuxTests("9.0","Latest")
}
post{
always{
sh 'rm -rf $WORKSPACE/xdmp'
}
success {
println("rh7_cluster_9.0-Nightly Completed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n All the End to End tests on rh7 cluster 9.0-Nightly of the branch $BRANCH_NAME passed and the next stage is to merge it to release branch if all the end-end tests pass',false,'rh7_cluster_9.0-Nightly Tests for $BRANCH_NAME Passed'
}
unstable {
println("rh7_cluster_9.0-Nightly Failed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n Some of the End to End tests of the branch $BRANCH_NAME on 9.0-Nightly rh7 cluster failed. Please fix the tests and create a PR or create a bug for the failures.',false,'rh7_cluster_9.0-Nightly Tests for $BRANCH_NAME Failed'
}
}
}
stage('rh7_cluster_9.0-11'){
agent { label 'dhfLinuxAgent'}
steps{
dhflinuxTests("9.0-11","Release")
}
post{
always{
sh 'rm -rf $WORKSPACE/xdmp'
}
success {
println("rh7_cluster_9.0-11 Tests Completed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n All the End to End tests on rh7 cluster 9.0-11 of the branch $BRANCH_NAME passed and the next stage is to merge it to release branch if all the end-end tests pass',false,'rh7_cluster_9.0-11 Tests for $BRANCH_NAME Passed'
}
unstable {
println("rh7_cluster_9.0-11 Tests Failed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n Some of the End to End tests of the branch $BRANCH_NAME on 9.0-11 rh7 cluster failed. Please fix the tests and create a PR or create a bug for the failures.',false,'rh7_cluster_9.0-11 Tests for $BRANCH_NAME Failed'
}
}
}
stage('rh7_cluster_9.0-12'){
agent { label 'dhfLinuxAgent'}
steps{
dhflinuxTests("9.0-12","Release")
}
post{
always{
sh 'rm -rf $WORKSPACE/xdmp'
}
success {
println("rh7_cluster_9.0-12 Tests Completed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n All the End to End tests on rh7 cluster 9.0-12 of the branch $BRANCH_NAME passed and the next stage is to merge it to release branch if all the end-end tests pass',false,'rh7_cluster_9.0-12 Tests for $BRANCH_NAME Passed'
}
unstable {
println("rh7_cluster_9.0-12 Tests Failed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n Some of the End to End tests of the branch $BRANCH_NAME on 9.0-12 rh7 cluster failed. Please fix the tests and create a PR or create a bug for the failures.',false,'rh7_cluster_9.0-12 Tests for $BRANCH_NAME Failed'
}
}
}
stage('rh7_cluster_10.0-3'){
agent { label 'dhfLinuxAgent'}
steps{
dhflinuxTests("10.0-3","Release");
}
post{
always{
sh 'rm -rf $WORKSPACE/xdmp'
}
success {
println("rh7_cluster_10.0-3 Tests Completed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n All the End to End tests on rh7 cluster 10.0-3 of the branch $BRANCH_NAME passed and the next stage is to merge it to release branch if all the end-end tests pass',false,'rh7_cluster_10.0-3 Tests for $BRANCH_NAME Passed'
}
unstable {
println("rh7_cluster_10.0-3 Tests Failed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n Some of the End to End tests of the branch $BRANCH_NAME on 10.0-3 rh7 cluster failed. Please fix the tests and create a PR or create a bug for the failures.',false,'rh7_cluster_10.0-3 Tests for $BRANCH_NAME Failed'
}
}
}
}
post{
success{
node('dhfLinuxAgent'){
sh 'export JAVA_HOME=`eval echo "$JAVA_HOME_DIR"`;export GRADLE_USER_HOME=$WORKSPACE$GRADLE_DIR;export M2_HOME=$MAVEN_HOME/bin;export PATH=$GRADLE_USER_HOME:$PATH:$MAVEN_HOME/bin;cd $WORKSPACE/data-hub;rm -rf $GRADLE_USER_HOME/caches;./gradlew clean;cp ~/.gradle/gradle.properties $GRADLE_USER_HOME;chmod 777 $GRADLE_USER_HOME/gradle.properties;./gradlew build -x test;./gradlew publish || true;'
}
}
}
}
stage('example projects parallel'){
when {
expression{
node('dhmaster'){
props = readProperties file:'data-hub/pipeline.properties';
println(props['ExecutionBranch'])
return (env.BRANCH_NAME==props['ExecutionBranch'])
}
}
}
parallel{
stage('dh5-example'){
agent { label 'dhfLinuxAgent'}
steps{
sh 'cd $WORKSPACE/data-hub/examples/dh-5-example;repo=" maven {url \'http://distro.marklogic.com/nexus/repository/maven-snapshots/\'}";sed -i "/repositories {/a$repo" build.gradle; '
copyRPM 'Release','10.0-3'
script{
props = readProperties file:'data-hub/pipeline.properties';
def dockerhost=setupMLDockerCluster 3
sh '''
docker exec -u builder -i '''+dockerhost+''' /bin/sh -c "export JAVA_HOME=`eval echo "$JAVA_HOME_DIR"`;\
export GRADLE_USER_HOME=$WORKSPACE$GRADLE_DIR; \
export M2_HOME=$MAVEN_HOME/bin; \
export PATH=$GRADLE_USER_HOME:$PATH:$MAVEN_HOME/bin; \
cd $WORKSPACE/data-hub/examples/dh-5-example; \
rm -rf $GRADLE_USER_HOME/caches; \
./gradlew -i hubInit -Ptesting=true; \
cp ../../marklogic-data-hub/gradle.properties .; \
./gradlew -i mlDeploy -Ptesting=true -PmlUsername=admin -PmlPassword=admin; \
./gradlew hubRunFlow -PflowName=ingestion_only-flow -Ptesting=true; \
./gradlew hubRunFlow -PflowName=ingestion_mapping-flow -Ptesting=true; \
./gradlew hubRunFlow -PflowName=ingestion_mapping_mastering-flow -Ptesting=true;
"
'''
}
}
post{
always{
sh 'rm -rf $WORKSPACE/xdmp';
}
success{
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n dh5example ran successfully on the branch $BRANCH_NAME next stage is to merge it to run quickstart tests',false,' dh5-example for $BRANCH_NAME Passed'
}
unstable{
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n dh5example Failed on the branch $BRANCH_NAME.',false,'dh5-example for $BRANCH_NAME Failed'
}
}
}
stage('dhf-customhook'){
agent { label 'dhfLinuxAgent'}
steps{
sh 'cd $WORKSPACE/data-hub/examples/dhf5-custom-hook;repo=" maven {url \'http://distro.marklogic.com/nexus/repository/maven-snapshots/\'}";sed -i "/repositories {/a$repo" build.gradle; '
copyRPM 'Release','10.0-3'
script{
props = readProperties file:'data-hub/pipeline.properties';
def dockerhost=setupMLDockerCluster 3
sh '''
docker exec -u builder -i '''+dockerhost+''' /bin/sh -c "export JAVA_HOME=`eval echo "$JAVA_HOME_DIR"`;\
export GRADLE_USER_HOME=$WORKSPACE$GRADLE_DIR; \
export M2_HOME=$MAVEN_HOME/bin; \
export PATH=$GRADLE_USER_HOME:$PATH:$MAVEN_HOME/bin; \
cd $WORKSPACE/data-hub/examples/dhf5-custom-hook; \
rm -rf $GRADLE_USER_HOME/caches; \
./gradlew -i hubInit -Ptesting=true; \
cp ../../marklogic-data-hub/gradle.properties .; \
./gradlew -i mlDeploy -Ptesting=true -PmlUsername=admin -PmlPassword=admin; \
./gradlew hubRunFlow -PflowName=LoadOrders -Ptesting=true; \
./gradlew hubRunFlow -PflowName=LoadOrders -Ptesting=true;
"
'''
}
}
post{
always{
sh 'rm -rf $WORKSPACE/xdmp';
}
success{
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n dh5-customhook ran successfully on the branch $BRANCH_NAME next stage is to merge it to run quickstart tests',false,' dh5-customhook for $BRANCH_NAME Passed'
}
unstable{
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n dh5-customhook Failed on the branch $BRANCH_NAME.',false,'dh5-customhook for $BRANCH_NAME Failed'
}
}
}
stage('mapping-example'){
agent { label 'dhfLinuxAgent'}
steps{
sh 'cd $WORKSPACE/data-hub/examples/mapping-example;repo=" maven {url \'http://distro.marklogic.com/nexus/repository/maven-snapshots/\'}";sed -i "/repositories {/a$repo" build.gradle; '
copyRPM 'Release','10.0-3'
script{
props = readProperties file:'data-hub/pipeline.properties';
def dockerhost=setupMLDockerCluster 3
sh '''
docker exec -u builder -i '''+dockerhost+''' /bin/sh -c "export JAVA_HOME=`eval echo "$JAVA_HOME_DIR"`;\
export GRADLE_USER_HOME=$WORKSPACE$GRADLE_DIR; \
export M2_HOME=$MAVEN_HOME/bin; \
export PATH=$GRADLE_USER_HOME:$PATH:$MAVEN_HOME/bin; \
cd $WORKSPACE/data-hub/examples/mapping-example; \
rm -rf $GRADLE_USER_HOME/caches; \
./gradlew -i hubInit -Ptesting=true; \
cp ../../marklogic-data-hub/gradle.properties .; \
./gradlew -i mlDeploy -Ptesting=true -PmlUsername=admin -PmlPassword=admin; \
./gradlew hubRunFlow -PflowName=jsonToJson -Ptesting=true; \
./gradlew hubRunFlow -PflowName=jsonToXml -Ptesting=true; \
./gradlew hubRunFlow -PflowName=xmlToJson -Ptesting=true; \
./gradlew hubRunFlow -PflowName=xmlToXml -Ptesting=true;
"
'''
}
}
post{
always{
sh 'rm -rf $WORKSPACE/xdmp';
}
success{
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n mapping-example ran successfully on the branch $BRANCH_NAME next stage is to merge it to run quickstart tests',false,' mapping-example for $BRANCH_NAME Passed'
}
unstable{
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n mapping-example Failed on the branch $BRANCH_NAME.',false,'mapping-example for $BRANCH_NAME Failed'
}
}
}
stage('smart-mastering-complete'){
agent { label 'dhfLinuxAgent'}
steps{
sh 'cd $WORKSPACE/data-hub/examples/smart-mastering-complete;repo=" maven {url \'http://distro.marklogic.com/nexus/repository/maven-snapshots/\'}";sed -i "/repositories {/a$repo" build.gradle; '
copyRPM 'Release','10.0-3'
script{
props = readProperties file:'data-hub/pipeline.properties';
def dockerhost=setupMLDockerCluster 3
sh '''
docker exec -u builder -i '''+dockerhost+''' /bin/sh -c "export JAVA_HOME=`eval echo "$JAVA_HOME_DIR"`;\
export GRADLE_USER_HOME=$WORKSPACE$GRADLE_DIR; \
export M2_HOME=$MAVEN_HOME/bin; \
export PATH=$GRADLE_USER_HOME:$PATH:$MAVEN_HOME/bin; \
cd $WORKSPACE/data-hub/examples/smart-mastering-complete; \
rm -rf $GRADLE_USER_HOME/caches; \
./gradlew -i hubInit -Ptesting=true; \
cp ../../marklogic-data-hub/gradle.properties .; \
./gradlew -i mlDeploy -Ptesting=true -PmlUsername=admin -PmlPassword=admin; \
./gradlew hubRunFlow -PflowName=persons -Ptesting=true;
"
'''
}
}
post{
always{
sh 'rm -rf $WORKSPACE/xdmp';
}
success{
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n smart-mastering-complete ran successfully on the branch $BRANCH_NAME next stage is to merge it to run quickstart tests',false,'smart-mastering-complete for $BRANCH_NAME Passed'
}
unstable{
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n smart-mastering-complete Failed on the branch $BRANCH_NAME.',false,'smart-mastering-complete for $BRANCH_NAME Failed'
}
}
}
}
}
stage('quick start linux parallel'){
when {
expression{
node('dhmaster'){
props = readProperties file:'data-hub/pipeline.properties';
println(props['ExecutionBranch'])
return (env.BRANCH_NAME==props['ExecutionBranch'])
}
}
}
parallel{
stage('qs_rh7_90-nightly'){
agent { label 'lnx-dhf-jenkins-slave-2'}
steps{
dhfqsLinuxTests("9.0","Latest")
}
post{
success {
println("qs_rh7_90-nightly Tests Completed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n All the End to End quick start tests on Rh7 90-nightly of the branch $BRANCH_NAME passed and the next stage is to merge it to release branch if all the end-end tests pass',false,'qs_rh7_90-nightly Tests for $BRANCH_NAME Passed'
}
unstable {
println("qs_rh7_90-nightly Tests Failed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n Some of the End to End quick start 90-nightly tests of the branch $BRANCH_NAME on rh7 failed. Please fix the tests and create a PR or create a bug for the failures.',false,'qs_rh7_90-nightly Tests for $BRANCH_NAME Failed'
}
}
}
stage('qs_rh7_10-nightly'){
agent { label 'lnx-dhf-jenkins-slave-2'}
steps{
dhfqsLinuxTests("10.0","Latest")
}
post{
success {
println("qs_rh7_10-nightly Tests Completed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n All the End to End quick start tests on Rh7 10-nightly of the branch $BRANCH_NAME passed and the next stage is to merge it to release branch if all the end-end tests pass',false,'qs_rh7_10-nightly Tests for $BRANCH_NAME Passed'
}
unstable {
println("qs_rh7_10-nightly Tests Failed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n Some of the End to End quick start 10-nightly tests of the branch $BRANCH_NAME on rh7 failed. Please fix the tests and create a PR or create a bug for the failures.',false,'qs_rh7_10-nightly Tests for $BRANCH_NAME Failed'
}
}
}
stage('qs_rh7_90-release'){
agent { label 'lnx-dhf-jenkins-slave-2'}
steps{
dhfqsLinuxTests("9.0-11","Release")
}
post{
success {
println("qs_rh7_90-release Tests Completed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n All the End to End quick start tests on Rh7 90-nightly of the branch $BRANCH_NAME passed and the next stage is to merge it to release branch if all the end-end tests pass',false,'qs_rh7_90-release Tests for $BRANCH_NAME Passed'
}
unstable {
println("qs_rh7_90-release Tests Failed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n Some of the End to End quick start 90-nightly tests of the branch $BRANCH_NAME on rh7 failed. Please fix the tests and create a PR or create a bug for the failures.',false,'qs_rh7_90-release Tests for $BRANCH_NAME Failed'
}
}
}
stage('qs_rh7_10-release'){
agent { label 'lnx-dhf-jenkins-slave-2'}
steps{
dhfqsLinuxTests("10.0-3","Release")
}
post{
success {
println("qs_rh7_10-release Tests Completed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n All the End to End quick start tests on Rh7 10-release of the branch $BRANCH_NAME passed and the next stage is to merge it to release branch if all the end-end tests pass',false,'qs_rh7_10-release Tests for $BRANCH_NAME Passed'
}
unstable {
println("qs_rh7_10-release Tests Failed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n Some of the End to End quick start 10-release tests of the branch $BRANCH_NAME on rh7 failed. Please fix the tests and create a PR or create a bug for the failures.',false,'qs_rh7_10-release Tests for $BRANCH_NAME Failed'
}
}
}
}
}
stage('Windows Core Parallel'){
when {
expression{
node('dhmaster'){
props = readProperties file:'data-hub/pipeline.properties';
println(props['ExecutionBranch'])
return (env.BRANCH_NAME==props['ExecutionBranch'])
}
}
}
parallel{
stage('w12_SN_9.0-Nightly'){
agent { label 'dhfWinagent'}
steps{
dhfWinTests("9.0","Latest")
}
post{
always{
bat 'RMDIR /S/Q xdmp'
}
success {
println("w12_SN_9.0-nightly Tests Completed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n All the End to End tests on Windows SN on latest 90 nightly server build of the branch $BRANCH_NAME passed and the next stage is to merge it to release branch if all the end-end tests pass',false,'w12_SN_90_nightly on latest server build Tests for $BRANCH_NAME Passed'
}
unstable {
println("w12_SN_9.0-nightly Tests Failed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n Some of the End to End tests of the branch $BRANCH_NAME on Windows SN latest 90 nightly server build w2k12 cluster failed. Please fix the tests and create a PR or create a bug for the failures.',false,'w12_SN_90_nightly Tests on latest server build for $BRANCH_NAME Failed'
}
}
}
stage('w12_SN_10.0-Nightly'){
agent { label 'dhfWinagent'}
steps{
dhfWinTests("10.0","Latest")
}
post{
always{
bat 'RMDIR /S/Q xdmp'
}
success {
println("w12_SN_10.0-nightly Tests Completed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n All the End to End tests on Windows SN on latest 10 nightly server build of the branch $BRANCH_NAME passed and the next stage is to merge it to release branch if all the end-end tests pass',false,'w12_SN_10_nightly on latest server build Tests for $BRANCH_NAME Passed'
}
unstable {
println("w12_SN_10.0-nightly Tests Failed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n Some of the End to End tests of the branch $BRANCH_NAME on Windows SN latest 10 nightly server build w2k12 cluster failed. Please fix the tests and create a PR or create a bug for the failures.',false,'w12_SN_10_nightly Tests on latest server build for $BRANCH_NAME Failed'
}
}
}
stage('w12_SN_9.0-12'){
agent { label 'dhfWinagent'}
steps{
dhfWinTests("9.0-12","Release")
}
post{
always{
bat 'RMDIR /S/Q xdmp'
}
success {
println("w12_SN_9.0-12 Tests Completed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n All the End to End tests on W2k12 SN 9.0-12 of the branch $BRANCH_NAME passed and the next stage is to merge it to release branch if all the end-end tests pass',false,'w12_SN_9.0-12 Tests for $BRANCH_NAME Passed'
}
unstable {
println("w12_SN_9.0-12 Tests Failed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n Some of the End to End tests of the branch $BRANCH_NAME on 9.0-12 w2k12 SN failed. Please fix the tests and create a PR or create a bug for the failures.',false,'w12_SN_9.0-12 Tests for $BRANCH_NAME Failed'
}
}
}
stage('w12_cluster_10.0-3'){
agent { label 'dhfWinCluster'}
steps{
script{
copyMSI "Release","10.0-3";
def pkgOutput=bat(returnStdout:true , script: '''
cd xdmp/src
for /f "delims=" %%a in ('dir /s /b *.msi') do set "name=%%~a"
echo %name%
''').trim().split();
def pkgLoc=pkgOutput[pkgOutput.size()-1]
gitCheckout 'ml-builds','https://github.com/marklogic/MarkLogic-Builds','master'
def bldOutput=bat(returnStdout:true , script: '''
cd ml-builds/scripts/lib/
CD
''').trim().split();
def bldPath=bldOutput[bldOutput.size()-1]
setupMLWinCluster bldPath,pkgLoc,"w2k16-10-dhf-2,w2k16-10-dhf-3"
bat 'cd data-hub & gradlew.bat clean'
bat 'cd data-hub & gradlew.bat marklogic-data-hub:test || exit /b 0'
bat 'cd data-hub & gradlew.bat ml-data-hub:test || exit /b 0'
bat 'cd data-hub & gradlew.bat web:test || exit /b 0'
junit '**/TEST-*.xml'
commitMessage = sh (returnStdout: true, script:'''
curl -u $Credentials -X GET "'''+githubAPIUrl+'''/git/commits/${GIT_COMMIT}" ''')
def slurper = new JsonSlurperClassic().parseText(commitMessage.toString().trim())
def commit=slurper.message.toString().trim();
JIRA_ID=commit.split(("\\n"))[0].split(':')[0].trim();
JIRA_ID=JIRA_ID.split(" ")[0];
commitMessage=null;
//jiraAddComment comment: 'Jenkins rh7_cluster_9.0-Nightly Test Results For PR Available', idOrKey: JIRA_ID, site: 'JIRA'
}
}
post{
always{
sh 'rm -rf $WORKSPACE/xdmp'
}
success {
println("w12_cluster_10.0-3 Tests Completed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n All the End to End tests on W2k12 cluster 10.0-3 of the branch $BRANCH_NAME passed and the next stage is to merge it to release branch if all the end-end tests pass',false,'w12_cluster_10.0-3 Tests for $BRANCH_NAME Passed'
}
unstable {
println("w12_cluster_10.0-3 Tests Failed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n Some of the End to End tests of the branch $BRANCH_NAME on 10.0-3 w2k12 cluster failed. Please fix the tests and create a PR or create a bug for the failures.',false,'w12_cluster_10.0-3 Tests for $BRANCH_NAME Failed'
}
}
}
}
}
stage('Merge PR to Release Branch'){
when {
expression{
props = readProperties file:'data-hub/pipeline.properties';
println(props['ExecutionBranch'])
return (env.BRANCH_NAME==props['ExecutionBranch'])
}
}
agent {label 'dhmaster'}
steps{
withCredentials([usernameColonPassword(credentialsId: '550650ab-ee92-4d31-a3f4-91a11d5388a3', variable: 'Credentials')]) {
script{
//JIRA_ID=env.CHANGE_TITLE.split(':')[0]
prResponse = sh (returnStdout: true, script:'''
curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"Automated PR for Release Branch\" , \"head\": \"5.1-develop\" , \"base\": \"'''+props['ReleaseBranch']+'''\" }' '''+githubAPIUrl+'''/pulls ''')
println(prResponse)
def slurper = new JsonSlurper().parseText(prResponse)
println(slurper.number)
prNumber=slurper.number;
}
}
withCredentials([usernameColonPassword(credentialsId: 'a0ec09aa-f339-44de-87c4-1a4936df44f5', variable: 'Credentials')]) {
sh "curl -u $Credentials -X POST -d '{\"event\": \"APPROVE\"}' "+githubAPIUrl+"/pulls/${prNumber}/reviews"
}
withCredentials([usernameColonPassword(credentialsId: '550650ab-ee92-4d31-a3f4-91a11d5388a3', variable: 'Credentials')]) {
script{
sh "curl -o - -s -w \"\n%{http_code}\n\" -X PUT -d '{\"commit_title\": \"$JIRA_ID: Merge pull request\", \"merge_method\": \"rebase\"}' -u $Credentials "+githubAPIUrl+"/pulls/${prNumber}/merge | tail -2 > mergeResult.txt"
def mergeResult = readFile('mergeResult.txt').trim()
if(mergeResult=="200"){
println("Merge successful")
}else{
println("Merge Failed")
sh 'exit 1'
}
}
}
}
post{
success {
println("Automated PR For Release branch created")
}
failure {
println("Creation of Automated PR Failed")
}
}
}
stage('Sanity Tests'){
when {
expression{
props = readProperties file:'data-hub/pipeline.properties';
println(props['ExecutionBranch'])
return (env.BRANCH_NAME==props['ReleaseBranch'])
}
}
agent { label 'dhfLinuxAgent'}
steps{
script{
props = readProperties file:'data-hub/pipeline.properties';
copyRPM 'Release','10.0-3'
setUpML '$WORKSPACE/xdmp/src/Mark*.rpm'
sh 'export JAVA_HOME=`eval echo "$JAVA_HOME_DIR"`;export GRADLE_USER_HOME=$WORKSPACE$GRADLE_DIR;export M2_HOME=$MAVEN_HOME/bin;export PATH=$GRADLE_USER_HOME:$PATH:$MAVEN_HOME/bin;cd $WORKSPACE/data-hub;rm -rf $GRADLE_USER_HOME/caches;./gradlew clean;./gradlew clean;./gradlew marklogic-data-hub:test || true;sleep 10s;./gradlew ml-data-hub:test || true;sleep 10s;./gradlew web:test || true;'
junit '**/TEST-*.xml'
commitMessage = sh (returnStdout: true, script:'''
curl -u $Credentials -X GET "'''+githubAPIUrl+'''/git/commits/${GIT_COMMIT}" ''')
def slurper = new JsonSlurperClassic().parseText(commitMessage.toString().trim())
def commit=slurper.message.toString().trim();
JIRA_ID=commit.split(("\\n"))[0].split(':')[0].trim();
JIRA_ID=JIRA_ID.split(" ")[0];
commitMessage=null;
//jiraAddComment comment: 'Jenkins Sanity Test Results For PR Available', idOrKey: JIRA_ID, site: 'JIRA'
}
}
post{
always{
sh 'rm -rf $WORKSPACE/xdmp'
}
success {
println("Sanity Tests Completed")
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n All the sanity tests of the branch $BRANCH_NAME passed and next stage is to release',false,'Sanity Tests for $BRANCH_NAME Passed'
script{
def transitionInput =[transition: [id: '31']]
//JIRA_ID=env.CHANGE_TITLE.split(':')[0]
//jiraTransitionIssue idOrKey: JIRA_ID, input: transitionInput, site: 'JIRA'
}
sendMail Email,'Run the release pipeline to release Datahub',false,'Datahub is ready for Release'
}
unstable {
println("Sanity Tests Failed")
sh 'mkdir -p MLLogs;cp -r /var/opt/MarkLogic/Logs/* $WORKSPACE/MLLogs/'
archiveArtifacts artifacts: 'MLLogs/**/*'
sendMail Email,'Check the Pipeline View Here: ${JENKINS_URL}/blue/organizations/jenkins/Datahub_CI/detail/$JOB_BASE_NAME/$BUILD_ID \n\n\n Check Console Output Here: ${BUILD_URL}/console \n\n\n Some of the Sanity tests of the branch $BRANCH_NAME on failed. Please fix the tests and create a PR or create a bug for the failures.',false,'Sanity Tests for $BRANCH_NAME Failed'
}
}
}
}
}