-
Notifications
You must be signed in to change notification settings - Fork 35
/
.evg.yml
1036 lines (917 loc) · 34 KB
/
.evg.yml
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
stepback: true
command_type: system
pre:
- func: "fetch source"
- func: "export variables"
post:
- func: "upload jar file"
- func: "upload unit test classes"
- func: "upload integration test classes"
- func: "upload unit test packages"
- func: "upload integration test packages"
- func: "upload unit test js"
- func: "upload integration test js"
- func: "upload unit test css "
- func: "upload integration test css "
- func: "upload unit test index"
- func: "upload integration test index"
- func: "upload xunit test results"
buildvariants:
- name: static-analysis
display_name: "Static Analysis"
run_on: [ ubuntu2204-small ]
tasks:
- spotless
- name: code-quality-and-correctness
display_name: "Code Quality and Security"
expansions:
_platform: ubuntu2204-64-jdk-8
run_on: [ ubuntu2204-small ]
tasks:
- name: semgrep
- name: sbom
- name: ssdlc-artifacts-snapshot
- name: ubuntu2204-64-jdk-8
display_name: Ubuntu 22.04 jdk-8
expansions:
_platform: ubuntu2204-64-jdk-8
run_on: ubuntu2204-large
tasks:
- name: "build"
- name: "test-unit"
- name: "test-mongo-sql-translate"
- name: "test-adf-integration"
# SQL-2289: integration tests. Use the actual mongosqltranslate library for testing instead of mock.
# - name: "test-dc-integration"
- name: amazon2-arm64-jdk-11
display_name: Amazon Linux 2 ARM64 jdk-11
expansions:
_platform: amazon2-arm64-jdk-11
run_on: amazon2-arm64-graviton3
tasks:
- name: "build"
- name: "test-unit"
- name: "test-adf-integration"
- name: release
display_name: "Release"
expansions:
_platform: ubuntu2204-64-jdk-8
run_on: ubuntu2204-small
tasks:
- name: "test-smoke"
- name: "publish-maven"
- name: "ssdlc-artifacts-release"
- name: "download-center-update"
tasks:
- name: "build"
commands:
- func: "build jdbc driver"
- name: "test-unit"
commands:
- func: "run unit test"
- name: "test-mongo-sql-translate"
commands:
- func: "run mongosqltranslate library load test"
- name: "test-adf-integration"
commands:
- func: "generate github token"
- func: "run adf integration test"
- name: "test-dc-integration"
commands:
- func: "run dc integration test"
- name: "test-smoke"
commands:
- func: "generate github token"
- func: "run smoke test"
- name: "publish-maven"
git_tag_only: true
depends_on:
- name: "test-smoke"
variant: "release"
- name: sbom
variant: code-quality-and-correctness
commands:
- func: "publish maven"
- func: "trace artifacts"
- name: spotless
commands:
- func: "check spotless"
- name: download-center-update
git_tag_only: true
depends_on:
- name: "publish-maven"
variant: "release"
commands:
- func: "update download center feed"
- name: semgrep
exec_timeout_secs: 3600 # 1h
commands:
- func: "static code analysis"
- name: sbom
commands:
- func: "generate sbom"
- func: "upload sbom"
- func: "push SBOM Lite to Silk"
- func: "pull augmented SBOM from Silk"
- func: "scan sbom"
- name: ssdlc-artifacts-release
run_on: ubuntu2204-small
git_tag_only: true
depends_on:
- name: "publish-maven"
variant: "release"
- name: semgrep
variant: code-quality-and-correctness
exec_timeout_secs: 300 # 5m
commands:
- func: "publish augmented SBOM"
- func: "publish static code analysis"
- func: "generate compliance report"
- func: "publish compliance report"
- name: ssdlc-artifacts-snapshot
run_on: ubuntu2204-small
allow_for_git_tag: false
depends_on:
- name: sbom
variant: code-quality-and-correctness
- name: semgrep
variant: code-quality-and-correctness
exec_timeout_secs: 300 # 5m
commands:
- func: "publish augmented SBOM"
- func: "publish static code analysis"
- func: "generate compliance report"
- func: "publish compliance report"
functions:
"push SBOM Lite to Silk":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongo-jdbc-driver
script: |
${PREPARE_SHELL}
cat << EOF > silkbomb.env
SILK_CLIENT_ID=${SILK_CLIENT_ID}
SILK_CLIENT_SECRET=${SILK_CLIENT_SECRET}
EOF
ls -lrt $SSDLC_DIR
echo "SBOM_LITE_NAME = $SBOM_LITE_NAME"
echo "-- Uploading initial SBOM Lite to Silk --"
docker run -i --platform="linux/amd64" --rm -v "$PWD":/pwd \
--env-file silkbomb.env \
artifactory.corp.mongodb.com/release-tools-container-registry-public-local/silkbomb:1.0 \
upload --silk-asset-group ${SILK_ASSET_GROUP} --sbom-in /pwd/artifacts/ssdlc/$SBOM_LITE_NAME
echo "-------------------------------"
"pull augmented SBOM from Silk":
- command: ec2.assume_role
params:
role_arn: ${assume_role_arn}
duration_seconds: 3600
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongo-jdbc-driver
script: |
${PREPARE_SHELL}
cat << EOF > silkbomb.env
SILK_CLIENT_ID=${SILK_CLIENT_ID}
SILK_CLIENT_SECRET=${SILK_CLIENT_SECRET}
EOF
echo "AUGMENTED_SBOM_NAME = $AUGMENTED_SBOM_NAME"
echo "-- Downloading augmented SBOM --"
docker run -i --platform="linux/amd64" --rm -v "$PWD":/pwd \
--env-file silkbomb.env \
artifactory.corp.mongodb.com/release-tools-container-registry-public-local/silkbomb:1.0 \
download --silk-asset-group ${SILK_ASSET_GROUP} --sbom-out /pwd/artifacts/ssdlc/$AUGMENTED_SBOM_NAME
echo "-------------------------------"
ls -lrt $SSDLC_DIR
- command: s3.put
params:
aws_key: ${AWS_ACCESS_KEY_ID}
aws_secret: ${AWS_SECRET_ACCESS_KEY}
aws_session_token: ${AWS_SESSION_TOKEN}
local_file: mongo-jdbc-driver/artifacts/ssdlc/${AUGMENTED_SBOM_NAME}
remote_file: artifacts/${version_id}/ssdlc/${AUGMENTED_SBOM_NAME}
content_type: application/json
bucket: evg-bucket-mongo-jdbc-driver
permissions: public-read
"publish augmented SBOM":
- command: ec2.assume_role
params:
role_arn: ${assume_role_arn}
duration_seconds: 3600
- command: s3.get
params:
aws_key: ${AWS_ACCESS_KEY_ID}
aws_secret: ${AWS_SECRET_ACCESS_KEY}
aws_session_token: ${AWS_SESSION_TOKEN}
local_file: artifacts/ssdlc/mongodb-jdbc-${MDBJDBC_VER}.sbom.json
remote_file: artifacts/${version_id}/ssdlc/${AUGMENTED_SBOM_NAME}
content_type: application/json
bucket: evg-bucket-mongo-jdbc-driver
- command: s3.put
params:
aws_key: ${release_aws_key}
aws_secret: ${release_aws_secret}
local_file: artifacts/ssdlc/mongodb-jdbc-${MDBJDBC_VER}.sbom.json
remote_file: mongo-jdbc-driver/mongodb-jdbc-${MDBJDBC_VER}.sbom.json
content_type: application/json
bucket: translators-connectors-releases
permissions: public-read
display_name: mongodb-jdbc-${MDBJDBC_VER}.sbom.json
"generate sbom":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongo-jdbc-driver
script: |
${PREPARE_SHELL}
set -o errexit
mkdir -p $SBOM_TOOL_DIR
echo "------------------------------------"
echo "Generating SBOM"
echo "------------------------------------"
./gradlew clean cyclonedxBom -PcyclonedxBomDestination=$SSDLC_DIR -PcyclonedxBomName=sbom_without_team_name
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongo-jdbc-driver
script: |
${PREPARE_SHELL}
set -o errexit
JQ_URL="https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64"
echo "-- Downloading JQ $JQ_URL --"
curl -L -o $SBOM_TOOL_DIR/jq "$JQ_URL" \
--silent \
--fail \
--max-time 60 \
--retry 5 \
--retry-delay 0
chmod +x ./$SBOM_TOOL_DIR/jq
echo "------------------------------------"
echo "Adding team name to SBOM"
echo "------------------------------------"
jq '.components[].properties += [{"name": "internal:team_responsible", "value": "Atlas SQL"}]' $SBOM_WITHOUT_TEAM_NAME > $SBOM_LITE
echo "------------------------------------"
echo "Done generating SBOM"
echo "------------------------------------"
"upload sbom":
- command: ec2.assume_role
params:
role_arn: ${assume_role_arn}
duration_seconds: 3600
- command: s3.put
params:
aws_key: ${AWS_ACCESS_KEY_ID}
aws_secret: ${AWS_SECRET_ACCESS_KEY}
aws_session_token: ${AWS_SESSION_TOKEN}
local_files_include_filter:
- ${SBOM_LITE_NAME}
remote_file: artifacts/${version_id}/ssdlc/
content_type: application/json
bucket: evg-bucket-mongo-jdbc-driver
permissions: public-read
"scan sbom":
command: shell.exec
type: test
params:
shell: bash
working_dir: mongo-jdbc-driver
script: |
${PREPARE_SHELL}
set -o errexit
# Install Grype
echo "-- Downloading Grype --"
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b $SBOM_TOOL_DIR
echo "------------------------------------"
echo "-- Scanning dependency for vulnerabilities --"
./$SBOM_TOOL_DIR/grype sbom:$SBOM_LITE --fail-on low
echo "---------------------------------------------"
echo "<<<< Done scanning SBOM"
"build jdbc driver":
command: shell.exec
type: test
params:
shell: bash
working_dir: mongo-jdbc-driver
script: |
${PREPARE_SHELL}
./gradlew -Dorg.gradle.java.home=${JAVA_HOME} clean -x test -x integrationTest spotlessApply build --rerun-tasks
"check spotless":
command: shell.exec
type: test
params:
shell: bash
working_dir: mongo-jdbc-driver
script: |
${PREPARE_SHELL}
./gradlew spotlessCheck
"run unit test":
command: shell.exec
type: test
params:
shell: bash
working_dir: mongo-jdbc-driver
script: |
${PREPARE_SHELL}
./gradlew -Dorg.gradle.java.home=${JAVA_HOME} clean test
"run mongosqltranslate library load test":
command: shell.exec
type: test
params:
shell: bash
working_dir: mongo-jdbc-driver
script: |
${PREPARE_SHELL}
set -e
# Test loading library from path specified in ENV variable
MONGOSQL_TRANSLATE_PATH="$PWD/src/test/resources/MongoSqlLibraryTest/libmongosqltranslate.so" \
./gradlew runMongoSQLTranslateLibTest -PtestMethod=testLibraryLoadingWithEnvironmentVariable
# Move library file to where MongoDriver class is located
mkdir -p build/classes/java/
mv -f src/test/resources/MongoSqlLibraryTest/libmongosqltranslate.so build/classes/java/
# Test loading library from same directory as where the JDBC driver is located
./gradlew runMongoSQLTranslateLibTest -PtestMethod=testLibraryLoadingFromDriverPath
"generate github token":
command: github.generate_token
params:
owner: 10gen
repo: mongohouse
expansion_name: github_token
"run adf integration test":
command: shell.exec
type: test
params:
env:
GITHUB_TOKEN: "${github_token}"
shell: bash
working_dir: mongo-jdbc-driver
script: |
${PREPARE_SHELL}
./resources/run_adf.sh start &&
./gradlew -Dorg.gradle.java.home=${JAVA_HOME} runDataLoader &&
./gradlew -Dorg.gradle.java.home=${JAVA_HOME} clean integrationTest \
-x test --tests ADFIntegrationTest > gradle_output.log 2>&1 &
GRADLE_PID=$!
echo "Gradle process started with PID $GRADLE_PID"
# On Amazon Linux 2 hosts, the gradlew integrationTest command was hanging indefinitely.
# This monitoring approach will detect build completion or failure even when the Gradle
# process doesn't terminate properly and allows the task to complete.
SECONDS=0
TIMEOUT=1800 # 30 minute timeout
while true; do
if grep -q "BUILD SUCCESSFUL" gradle_output.log; then
echo "Build successful!"
EXITCODE=0
break
fi
if grep -q "BUILD FAILED" gradle_output.log; then
echo "Build failed!"
EXITCODE=1
break
fi
if (( SECONDS > TIMEOUT )); then
echo "$TIMEOUT second timeout reached. Exiting with failure."
EXITCODE=1
break
fi
# Check if Gradle process is still running
if ! kill -0 $GRADLE_PID 2>/dev/null; then
echo "Gradle process has finished."
wait $GRADLE_PID
EXITCODE=$?
break
fi
sleep 5
done
cat gradle_output.log
kill $GRADLE_PID 2>/dev/null || true
./resources/run_adf.sh stop
echo "Integration test exit code: $EXITCODE"
exit $EXITCODE
"run dc integration test":
command: shell.exec
type: test
params:
shell: bash
working_dir: mongo-jdbc-driver
script: |
${PREPARE_SHELL}
case ${_platform} in
ubuntu2204-64-jdk-8 | ubuntu2204-64-jdk-11)
mdb_version_com="mongodb-linux-x86_64-ubuntu2204-7.0.14"
mdb_version_ent="mongodb-linux-x86_64-enterprise-ubuntu2204-7.0.14"
arch="x64"
;;
*)
echo "ERROR: invalid value for \${_platform}: '$_platform'"
echo "Allowed values: 'ubuntu2204-64-jdk-8', 'ubuntu2204-64-jdk-11'"
exit 1
;;
esac
# Move library file to where MongoDriver class is located
mkdir -p build/classes/java/
mv -f src/test/resources/MongoSqlLibraryTest/libmongosqltranslate.so build/classes/java/
# Download and run local community and enterprise mongods.
./resources/start_local_mdb.sh $mdb_version_com $mdb_version_ent $arch
# Run the tests.
./gradlew integrationTest \
-x test --tests DCIntegrationTest > gradle_output.log 2>&1 &
GRADLE_PID=$!
echo "Gradle process started with PID $GRADLE_PID"
# On Amazon Linux 2 hosts, the gradlew integrationTest command was hanging indefinitely.
# This monitoring approach will detect build completion or failure even when the Gradle
# process doesn't terminate properly and allows the task to complete.
SECONDS=0
TIMEOUT=1800 # 30 minute timeout
while true; do
if grep -q "BUILD SUCCESSFUL" gradle_output.log; then
echo "Build successful!"
EXITCODE=0
break
fi
if grep -q "BUILD FAILED" gradle_output.log; then
echo "Build failed!"
EXITCODE=1
break
fi
if (( SECONDS > TIMEOUT )); then
echo "$TIMEOUT second timeout reached. Exiting with failure."
EXITCODE=1
break
fi
# Check if Gradle process is still running
if ! kill -0 $GRADLE_PID 2>/dev/null; then
echo "Gradle process has finished."
wait $GRADLE_PID
EXITCODE=$?
break
fi
sleep 5
done
cat gradle_output.log
kill $GRADLE_PID 2>/dev/null || true
pkill mongod
echo "Integration test exit code: $EXITCODE"
exit $EXITCODE
"trace artifacts":
command: papertrail.trace
params:
work_dir: mongo-jdbc-driver
key_id: ${papertrail_id}
secret_key: ${papertrail_key}
product: mongo-jdbc-driver
version: ${MDBJDBC_VER}
filenames:
- "build/libs/*.jar"
"run smoke test":
command: shell.exec
type: test
params:
env:
GITHUB_TOKEN: "${github_token}"
working_dir: mongo-jdbc-driver
script: |
${PREPARE_SHELL}
./resources/run_adf.sh start &&
./gradlew runDataLoader &&
./gradlew clean shadowJar &&
./gradlew :smoketest:test -Psmoketest
EXITCODE=$?
./resources/run_adf.sh stop
exit $EXITCODE
"export variables":
- command: shell.exec
params:
shell: bash
silent: true
working_dir: mongo-jdbc-driver
script: |
# set the state needed irrespective of _platform
ARTIFACTS_DIR=artifacts
S3_ARTIFACTS_DIR='mongo-jdbc-driver/artifacts/${version_id}/${build_variant}'
AUGMENTED_SBOM_NAME="mongo-jdbc-driver.augmented.sbom.json"
COMPLIANCE_REPORT_NAME="mongodb-jdbc-compliance-report.md"
STATIC_CODE_ANALYSIS_NAME="mongo-jdbc-driver.sast.sarif"
# Get the version from trigger.
# Tag triggered runs are releases and the version is set in the tag.
# Other runs are snapshot builds (periodic builds or patches)
if [[ "${triggered_by_git_tag}" != "" ]]; then
export MDBJDBC_VER=$(echo ${triggered_by_git_tag} | sed s/v//)
else
export MDBJDBC_VER=snapshot
fi
case ${_platform} in
ubuntu2204-64-jdk-8)
JAVA_HOME=/opt/java/jdk8
;;
ubuntu2204-64-jdk-11)
JAVA_HOME=/opt/java/jdk11
;;
amazon2-arm64-jdk-11)
JAVA_HOME=/usr/lib/jvm/java-11
;;
*)
echo "ERROR: invalid value for \${_platform}: '$_platform'"
echo "Allowed values: 'amazon2-arm64-jdk-11', 'ubuntu2204-64-jdk-8', 'ubuntu2204-64-jdk-11'"
exit 1
;;
esac
# export any environment variables that will be needed by subprocesses
export PROJECT_DIRECTORY="$(pwd)"
export SBOM_LITE_NAME="mongo-jdbc-driver.cdx.json"
export AUGMENTED_SBOM_NAME="$AUGMENTED_SBOM_NAME"
export COMPLIANCE_REPORT_NAME=$COMPLIANCE_REPORT_NAME
export STATIC_CODE_ANALYSIS_NAME=$STATIC_CODE_ANALYSIS_NAME
export SSDLC_DIR="$ARTIFACTS_DIR/ssdlc"
mkdir -p $SSDLC_DIR
# create expansions from values calculated above
mkdir -p $ARTIFACTS_DIR
cat <<EOT > $ARTIFACTS_DIR/expansions.yml
S3_ARTIFACTS_DIR: "$S3_ARTIFACTS_DIR"
MDBJDBC_VER: "$MDBJDBC_VER"
JAVA_HOME: "$JAVA_HOME"
SBOM_LITE_NAME: "$SBOM_LITE_NAME"
AUGMENTED_SBOM_NAME: "$AUGMENTED_SBOM_NAME"
STATIC_CODE_ANALYSIS_NAME: "$STATIC_CODE_ANALYSIS_NAME"
COMPLIANCE_REPORT_NAME: "$COMPLIANCE_REPORT_NAME"
SSDLC_DIR: "$SSDLC_DIR"
PREPARE_SHELL: |
export ADF_TEST_LOCAL_USER=${adf_test_local_user}
export ADF_TEST_LOCAL_PWD=${adf_test_local_pwd}
export ADF_TEST_LOCAL_AUTH_DB=${adf_test_local_auth_db}
export MDB_TEST_LOCAL_PORT=${mdb_test_local_port}
export ADF_TEST_USER=${adf_test_user}
export ADF_TEST_PWD=${adf_test_pwd}
export ADF_TEST_HOST=${adf_test_host}
export ADF_TEST_AUTH_DB=${adf_test_auth_db}
export SRV_TEST_HOST=${srv_test_host}
export SRV_TEST_USER=${srv_test_user}
export SRV_TEST_PWD=${srv_test_pwd}
export SRV_TEST_AUTH_DB=${srv_test_auth_db}
export LOCAL_MDB_PORT_COM=${local_mdb_port_com}
export LOCAL_MDB_PORT_ENT=${local_mdb_port_ent}
export LOCAL_MDB_USER=${local_mdb_user}
export LOCAL_MDB_PWD=${local_mdb_pwd}
export JAVA_HOME=${JAVA_HOME}
export PROJECT_DIRECTORY=${PROJECT_DIRECTORY}
export MDBJDBC_VER=${MDBJDBC_VER}
# ssdlc relevant variables
export SBOM_WITHOUT_TEAM_NAME=$ARTIFACTS_DIR/ssdlc/sbom_without_team_name.json
export SBOM_TOOL_DIR="sbom_generations"
export SBOM_LITE_NAME="$SBOM_LITE_NAME"
export AUGMENTED_SBOM_NAME="$AUGMENTED_SBOM_NAME"
export SSDLC_DIR="$SSDLC_DIR"
export SBOM_LITE="$ARTIFACTS_DIR/ssdlc/$SBOM_LITE_NAME"
export COMPLIANCE_REPORT_NAME="$COMPLIANCE_REPORT_NAME"
export STATIC_CODE_ANALYSIS_NAME="$STATIC_CODE_ANALYSIS_NAME"
EOT
- command: expansions.update
params:
file: mongo-jdbc-driver/artifacts/expansions.yml
"fetch jdbc files":
- command: s3.get
params:
working_dir: mongo-jdbc-driver
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: mongo-jdbc-driver/build/libs/mongodb-jdbc-${MDBJDBC_VER}.jar
remote_file: ${S3_ARTIFACTS_DIR}/mongodb-jdbc-${MDBJDBC_VER}.jar
bucket: mciuploads
"fetch source":
- command: shell.exec
params:
shell: bash
silent: true
script: |
rm -rf mongo-jdbc-driver
- command: git.get_project
params:
directory: mongo-jdbc-driver
"upload unit test classes":
- command: s3.put
params:
silent: true
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_files_include_filter:
- mongo-jdbc-driver/build/reports/tests/test/classes/*.html
remote_file: ${S3_ARTIFACTS_DIR}/test/classes/
content_type: text/html
bucket: mciuploads
permissions: public-read
display_name: "Unit Test Classes"
visibility: none
"upload integration test classes":
- command: s3.put
params:
silent: true
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_files_include_filter:
- mongo-jdbc-driver/build/reports/tests/integrationTest/classes/*.html
remote_file: ${S3_ARTIFACTS_DIR}/integrationTest/classes/
content_type: text/html
bucket: mciuploads
permissions: public-read
display_name: "Integration Test Classes"
visibility: none
"upload unit test packages":
- command: s3.put
params:
silent: true
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_files_include_filter:
- mongo-jdbc-driver/build/reports/tests/test/packages/*.html
remote_file: ${S3_ARTIFACTS_DIR}/test/packages/
content_type: text/html
bucket: mciuploads
permissions: public-read
display_name: "Unit Test Packages"
visibility: none
"upload integration test packages":
- command: s3.put
params:
silent: true
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_files_include_filter:
- mongo-jdbc-driver/build/reports/tests/integrationTest/packages/*.html
remote_file: ${S3_ARTIFACTS_DIR}/integrationTest/packages/
content_type: text/html
bucket: mciuploads
permissions: public-read
display_name: "Integration Test Packages"
visibility: none
"upload unit test index":
- command: s3.put
params:
silent: true
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: mongo-jdbc-driver/build/reports/tests/test/index.html
remote_file: ${S3_ARTIFACTS_DIR}/test/index.html
content_type: text/html
bucket: mciuploads
permissions: public-read
display_name: "Unit Test Results"
"upload integration test index":
- command: s3.put
params:
silent: true
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: mongo-jdbc-driver/build/reports/tests/integrationTest/index.html
remote_file: ${S3_ARTIFACTS_DIR}/integrationTest/index.html
content_type: text/html
bucket: mciuploads
permissions: public-read
display_name: "Integration Test Results"
"upload unit test css ":
- command: s3.put
params:
silent: true
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_files_include_filter:
- mongo-jdbc-driver/build/reports/tests/test/css/*.css
remote_file: ${S3_ARTIFACTS_DIR}/test/css/
content_type: text/css
bucket: mciuploads
permissions: public-read
display_name: "Unit Test CSS"
visibility: none
"upload integration test css ":
- command: s3.put
params:
silent: true
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_files_include_filter:
- mongo-jdbc-driver/build/reports/tests/integrationTest/css/*.css
remote_file: ${S3_ARTIFACTS_DIR}/integrationTest/css/
content_type: text/css
bucket: mciuploads
permissions: public-read
display_name: "Integration Test CSS"
visibility: none
"upload unit test js":
- command: s3.put
params:
silent: true
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_files_include_filter:
- mongo-jdbc-driver/build/reports/tests/test/js/*.js
remote_file: ${S3_ARTIFACTS_DIR}/test/js/
content_type: application/javascript
bucket: mciuploads
permissions: public-read
display_name: "Unit Test JS"
visibility: none
"upload integration test js":
- command: s3.put
params:
silent: true
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_files_include_filter:
- mongo-jdbc-driver/build/reports/tests/integrationTest/js/*.js
remote_file: ${S3_ARTIFACTS_DIR}/integrationTest/js/
content_type: application/javascript
bucket: mciuploads
permissions: public-read
display_name: "Integration Test JS"
visibility: none
"upload xunit test results":
- command: attach.xunit_results
params:
silent: true
file: mongo-jdbc-driver/build/test-results/*/TEST-*.xml
"upload jar file":
- command: s3.put
params:
silent: true
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: mongo-jdbc-driver/build/libs/mongodb-jdbc-${MDBJDBC_VER}.jar
remote_file: ${S3_ARTIFACTS_DIR}/mongodb-jdbc-${MDBJDBC_VER}.jar
content_type: application/java-archive
bucket: mciuploads
permissions: public-read
display_name: "JDBC Driver (.jar)"
"publish maven":
- command: shell.exec
type: test
params:
shell: bash
silent: true
working_dir: mongo-jdbc-driver
script: |
PROJECT_DIRECTORY="$(pwd)" NEXUS_PROFILE_ID=${NEXUS_PROFILE_ID} NEXUS_TOKEN_NAME=${NEXUS_TOKEN_NAME} NEXUS_TOKEN=${NEXUS_TOKEN} NEXUS_URL=${NEXUS_URL} SIGNING_PASSWORD=${SIGNING_PASSWORD} SIGNING_KEY_ID=${SIGNING_KEY_ID} RING_FILE_GPG_BASE64=${RING_FILE_GPG_BASE64} ./gradle/publish.sh
"update download center feed":
- command: shell.exec
params:
shell: bash
working_dir: mongo-jdbc-driver
script: |
echo "Version = ${MDBJDBC_VER}"
sed -i "s@{RELEASE_VERSION}@${MDBJDBC_VER}@" mongo-jdbc-downloads_template.json
echo "-------------------------"
cat mongo-jdbc-downloads_template.json
echo "-------------------------"
- command: s3.put
params:
aws_key: ${release_aws_key}
aws_secret: ${release_aws_secret}
local_file: mongo-jdbc-driver/mongo-jdbc-downloads_template.json
remote_file: mongo-jdbc-driver/mongo-jdbc-downloads.json
bucket: translators-connectors-releases
permissions: public-read
content_type: application/json
"static code analysis":
- command: ec2.assume_role
params:
role_arn: ${assume_role_arn}
duration_seconds: 3600
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongo-jdbc-driver
script: |
echo "Running static code analysis with Semgrep..."
venv='venv'
# Setup or use the existing virtualenv for semgrep
if [[ -f "$venv/bin/activate" ]]; then
echo 'using existing virtualenv'
. "$venv"/bin/activate
else
echo 'Creating new virtualenv'
python3 -m virtualenv "$venv"
echo 'Activating new virtualenv'
. "$venv"/bin/activate
fi
python3 -m pip install semgrep
# confirm
semgrep --version
set +e
semgrep --config p/java --verbose --exclude "vendor" --error --severity=ERROR --sarif-output=${STATIC_CODE_ANALYSIS_NAME} > mongo-jdbc-driver.sast.cmd.verbose.out 2>&1
SCAN_RESULT=$?
set -e
# Exit with a failure if the scan found an issue
exit $SCAN_RESULT
- command: s3.put
params:
aws_key: ${AWS_ACCESS_KEY_ID}
aws_secret: ${AWS_SECRET_ACCESS_KEY}
aws_session_token: ${AWS_SESSION_TOKEN}
local_files_include_filter:
- mongo-jdbc-driver.sast.*
remote_file: artifacts/${version_id}/ssdlc/
content_type: application/json
bucket: evg-bucket-mongo-jdbc-driver
permissions: public-read
"publish static code analysis":
- command: ec2.assume_role
params:
role_arn: ${assume_role_arn}
duration_seconds: 3600
- command: s3.get
params:
aws_key: ${AWS_ACCESS_KEY_ID}
aws_secret: ${AWS_SECRET_ACCESS_KEY}
aws_session_token: ${AWS_SESSION_TOKEN}
local_file: artifacts/ssdlc/mongodb-jdbc-${MDBJDBC_VER}.sast.sarif
remote_file: artifacts/${version_id}/ssdlc/${STATIC_CODE_ANALYSIS_NAME}
content_type: application/json
bucket: evg-bucket-mongo-jdbc-driver
- command: s3.put
params:
aws_key: ${release_aws_key}
aws_secret: ${release_aws_secret}
local_file: artifacts/ssdlc/mongodb-jdbc-${MDBJDBC_VER}.sast.sarif
remote_file: mongo-jdbc-driver/mongodb-jdbc-${MDBJDBC_VER}.sast.sarif
content_type: application/json
bucket: translators-connectors-releases
permissions: public-read
display_name: mongodb-jdbc-${MDBJDBC_VER}.sast.sarif
"generate compliance report":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongo-jdbc-driver
script: |
echo "Author = ${author}"
echo "Author email = ${author_email}"
echo "Version = ${MDBJDBC_VER}"
SBOM_URL="https://translators-connectors-releases.s3.amazonaws.com/mongo-jdbc-driver/mongodb-jdbc-${MDBJDBC_VER}.sbom.json"
SARIF_URL="https://translators-connectors-releases.s3.amazonaws.com/mongo-jdbc-driver/mongodb-jdbc-${MDBJDBC_VER}.sast.sarif"
echo "Sbom url = $SBOM_URL"
echo "Sarif Url = $SARIF_URL"
echo "----- Generating ${COMPLIANCE_REPORT_NAME} -----"
# Copy template
cp resources/release/mongo_jdbc_compliance_report_template.md ${COMPLIANCE_REPORT_NAME}
# Update the version
echo "Update the version"
echo "sed -i.bu "s,%VERSION%,${MDBJDBC_VER},g" ${COMPLIANCE_REPORT_NAME}"
sed -i.bu "s,%VERSION%,${MDBJDBC_VER},g" ${COMPLIANCE_REPORT_NAME}
# Update the SBOM link
echo "Update the SBOM link"
echo "sed -i.bu "s,%SBOM_URL%,$SBOM_URL,g"${COMPLIANCE_REPORT_NAME}"
sed -i.bu "s,%SBOM_URL%,$SBOM_URL,g" ${COMPLIANCE_REPORT_NAME}
# Update the SARIF link
echo "Update the SARIF link"
echo "sed -i.bu "s,%SARIF_URL%,$SARIF_URL,g" ${COMPLIANCE_REPORT_NAME}"
sed -i.bu "s,%SARIF_URL%,$SARIF_URL,g" ${COMPLIANCE_REPORT_NAME}
# Update the author information
echo "Update the author name"
echo "sed -i.bu "s,%AUTHOR%,${author},g" ${COMPLIANCE_REPORT_NAME}"
sed -i.bu "s,%AUTHOR%,${author},g" ${COMPLIANCE_REPORT_NAME}
echo "update the author email"
echo "sed -i.bu "s,%AUTHOR_EMAIL%,${author_email},g" ${COMPLIANCE_REPORT_NAME}"
sed -i.bu "s,%AUTHOR_EMAIL%,${author_email},g" ${COMPLIANCE_REPORT_NAME}
echo "---------------------------"
- command: ec2.assume_role
params: