forked from DataDog/datadog-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
1242 lines (1130 loc) · 52.3 KB
/
.gitlab-ci.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
stages:
- source_test
- binary_build
- integration_test
- package_build
- check_deploy
- testkitchen_deploy
- testkitchen_testing
- testkitchen_cleanup
- image_build
- image_deploy
- deploy
- deploy_invalidate
- e2e
variables:
# The SRC_PATH is in the GOPATH of the builders which
# currently is /go
SRC_PATH: /go/src/github.com/DataDog/datadog-agent
# Directory in which we execute the omnibus build.
# For an unknown reason, it does not go well with
# a ruby dependency if we build directly into $CI_PROJECT_DIR/.omnibus
OMNIBUS_BASE_DIR: /.omnibus
# Directory in which we put the artifacts after the build
# Must be in $CI_PROJECT_DIR
OMNIBUS_PACKAGE_DIR: $CI_PROJECT_DIR/.omnibus/pkg/
# Directory in which we execute the omnibus build for SUSE
# as we want to separate the RPM built for this distro.
OMNIBUS_BASE_DIR_SUSE: /.omnibus/suse
# Directory in which we put the artifacts after the build
# Must be in $CI_PROJECT_DIR
OMNIBUS_PACKAGE_DIR_SUSE: $CI_PROJECT_DIR/.omnibus/suse/pkg
OMNIBUS_BASE_DIR_WIN: c:\omni-base\$CI_RUNNER_ID
OMNIBUS_BASE_DIR_WIN_OMNIBUS: c:/omni-base/$CI_RUNNER_ID
DD_AGENT_TESTING_DIR: $CI_PROJECT_DIR/test/kitchen
STATIC_BINARIES_DIR: bin/static
DOGSTATSD_BINARIES_DIR: bin/dogstatsd
AGENT_BINARIES_DIR: bin/agent
CLUSTER_AGENT_BINARIES_DIR: bin/datadog-cluster-agent
DEB_S3_BUCKET: apt.datad0g.com
RPM_S3_BUCKET: yum.datad0g.com
WIN_S3_BUCKET: dd-agent-mstesting
ANDROID_S3_BUCKET: dd-agent-androidtesting
DEB_RPM_BUCKET_BRANCH: nightly # branch of the DEB_S3_BUCKET and RPM_S3_BUCKET repos to release to, 'nightly' or 'beta'
DEB_TESTING_S3_BUCKET: apttesting.datad0g.com
RPM_TESTING_S3_BUCKET: yumtesting.datad0g.com
WINDOWS_TESTING_S3_BUCKET: $WIN_S3_BUCKET/pipelines/$CI_PIPELINE_ID
WINDOWS_BUILDS_S3_BUCKET: $WIN_S3_BUCKET/builds
ANDROID_BUILDS_S3_BUCKET: $ANDROID_S3_BUCKET/builds
DEB_RPM_TESTING_BUCKET_BRANCH: testing # branch of the DEB_TESTING_S3_BUCKET and RPM_TESTING_S3_BUCKET repos to release to, 'testing'
DD_REPO_BRANCH_NAME: $CI_COMMIT_REF_NAME
S3_CP_OPTIONS: --only-show-errors --region us-east-1 --sse AES256
S3_CP_CMD: aws s3 cp $S3_CP_OPTIONS
S3_ARTEFACTS_URI: s3://dd-ci-artefacts-build-stable/$CI_PROJECT_NAME/$CI_PIPELINE_ID
S3_OMNIBUS_CACHE_BUCKET: dd-ci-datadog-agent-omnibus-cache-build-stable
S3_DSD6_URI: s3://dsd6-staging/linux
RELEASE_VERSION: nightly
# Default before_script for all the jobs. If you create a new job and don't want this to execute
# you NEED to overwrite it.
before_script:
- echo running default before_script
- cd $SRC_PATH
- pip install --upgrade --ignore-installed pip setuptools
- pip install -r requirements.txt
- inv -e deps
#
# Trigger conditions
#
# run job only when triggered by an external tool (ex: Jenkins). This is used
# for jobs that run both on nightlies and tags
.run_when_triggered: &run_when_triggered
only:
- triggers
# anchor to trigger test kitchen setup, run, and cleanup (so all stages
# are run if one stage is run). Triggers as defined:
# - master
# - tags (a tagged build)
# - triggers (as above, when triggered by an external tool like jenkins)
# - web (when the build is triggered by a specific build request through the
# web interface. This way, if a kitchen run is desired on a specific branch,
# it can be triggered by requesting a specific build)
#
.run_when_testkitchen_triggered: &run_when_testkitchen_triggered
only:
- master
- tags
- triggers
- web
# run job only when triggered by an external tool (ex: Jenkins) and when
# RELEASE_VERSION is NOT "nightly". In this setting we are building either a
# new tagged version of the agent (an RC for example). In both cases the
# artifacts should be uploaded to our staging repository.
.run_when_triggered_on_tag: &run_when_triggered_on_tag
only:
refs:
- triggers
except: # we have to use except since gitlab doens't handle '!=' operator
variables:
- $RELEASE_VERSION == "nightly"
- $RELEASE_VERSION == "" # no RELEASE_VERSION means a nightly build for omnibus
# run job only when triggered by an external tool (ex: Jenkins) and when
# RELEASE_VERSION is "nightly". In this setting we build from master and update
# the nightly build for windows, linux and docker.
.run_when_triggered_on_nightly: &run_when_triggered_on_nightly
only:
refs:
- triggers
variables:
- $RELEASE_VERSION == "nightly"
#
# Job conditions
#
# run job when building Datadog Cluster Agent release tag
.run_on_cluster_agent_tag: &run_on_cluster_agent_tag
only:
refs:
- tags
variables:
- $CI_COMMIT_TAG =~ /^dca-([\d.-]|rc)+$/
# skip job when building Datadog Cluster Agent release tag
.skip_on_cluster_agent_tag: &skip_on_cluster_agent_tag
except:
refs:
- tags
variables:
- $CI_COMMIT_TAG =~ /^dca-([\d.-]|rc)+$/
#
# source_test
#
# run tests for deb-x64
run_tests_deb-x64:
stage: source_test
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/deb_x64:latest
tags: [ "runner:main", "size:2xlarge" ]
script:
- inv -e test --race --profile --cpus 4
# run tests for rpm-x64
run_test_rpm-x64:
stage: source_test
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/rpm_x64:latest
tags: [ "runner:main", "size:2xlarge" ]
script:
# Exclude systemd because it cannot succeed on Centos 6: the image doesn't have the shared object required by
# https://github.com/coreos/go-systemd/blob/c8cc474ba8655dfbdb0ac7fcc09b7faf5b643caf/sdjournal/functions.go#L46
# This is OK because the test on systemd still runs on the debian image above
- inv -e test --race --profile --cpus 4 --build-exclude=systemd
# scan the dependencies for security vulnerabilities with snyk
run_security_scan_test:
stage: source_test
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/snyk:latest
tags: ["runner:main", "size:large"]
only:
- master
before_script:
# this image isn't built in the datadog-agent-builders repo
# it doesn't have invoke so we install the dependencies without invoke
- mkdir -p $GOPATH/src/github.com/DataDog/datadog-agent
- rsync -azr --delete ./ $GOPATH/src/github.com/DataDog/datadog-agent
- cd $GOPATH/src/github.com/DataDog/datadog-agent
- pip install -r requirements.txt
- inv deps
script:
- set +x # don't print the api key to the logs
- SNYK_TOKEN=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.snyk_token --with-decryption --query "Parameter.Value" --out text)
snyk monitor # send the list of the dependencies to snyk
#
# binary_build
#
# build dogstatsd static for deb-x64
build_dogstatsd_static-deb_x64:
stage: binary_build
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/deb_x64:latest
tags: [ "runner:main", "size:large" ]
script:
- inv -e dogstatsd.build --static
- $S3_CP_CMD $SRC_PATH/$STATIC_BINARIES_DIR/dogstatsd $S3_ARTEFACTS_URI/static/dogstatsd
# build puppy agent for deb-x64, to make sure the build is not broken because of build flags
build_puppy_agent-deb_x64:
stage: binary_build
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/deb_x64:latest
tags: [ "runner:main", "size:large" ]
script:
- inv -e agent.build --puppy
- $S3_CP_CMD $SRC_PATH/$AGENT_BINARIES_DIR/agent $S3_ARTEFACTS_URI/puppy/agent
# build puppy agent for ARM, to make sure the build is not broken because of build targets
build_puppy_agent-deb_x64_arm:
stage: binary_build
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/deb_x64:latest
tags: [ "runner:main", "size:large" ]
script:
- GOOS=linux GOARCH=arm inv -e agent.build --puppy
# build dogstatsd for deb-x64
build_dogstatsd-deb_x64:
stage: binary_build
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/deb_x64:latest
tags: [ "runner:main", "size:large" ]
script:
- inv -e dogstatsd.build
- $S3_CP_CMD $SRC_PATH/$DOGSTATSD_BINARIES_DIR/dogstatsd $S3_ARTEFACTS_URI/dogstatsd/dogstatsd
# build cluster-agent bin
cluster_agent-build:
stage: binary_build
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/deb_x64:latest
tags: [ "runner:main", "size:large" ]
script:
- inv -e cluster-agent.build
- $S3_CP_CMD $SRC_PATH/$CLUSTER_AGENT_BINARIES_DIR/datadog-cluster-agent $S3_ARTEFACTS_URI/datadog-cluster-agent
- $S3_CP_CMD $SRC_PATH/Dockerfiles/cluster-agent/datadog-cluster.yaml $S3_ARTEFACTS_URI/datadog-cluster.yaml
- $S3_CP_CMD --recursive $SRC_PATH/$CLUSTER_AGENT_BINARIES_DIR/dist/templates $S3_ARTEFACTS_URI/dist/templates
#
# integration_test
# run benchmarks on deb
# run_benchmarks-deb_x64:
# stage: integration_test
# image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/deb_x64:latest
# allow_failure: true # FIXME: this was set to true to temporarily unblock the pipeline
# tags: [ "runner:main", "size:large" ]
# script:
# - inv -e bench.aggregator
# # FIXME: in our docker image, non ascii characters printed by the benchmark
# # make invoke traceback. For now, the workaround is to call the benchmarks
# # manually
# - inv -e bench.build-dogstatsd
# - set +x # make sure we don't output the creds to the build log
# - DD_AGENT_API_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.dd_agent_api_key --with-decryption --query "Parameter.Value" --out text)
# # dogstatsd validation - not really benchmarking: gitlab isn't the right place to do this.
# - ./bin/benchmarks/dogstatsd -pps=20000 -dur 30 -ser 5 -branch $DD_REPO_BRANCH_NAME -api-key $DD_AGENT_API_KEY
# artifacts:
# expire_in: 2 weeks
# paths:
# - benchmarks
# check the size of the static dogstatsd binary
run_dogstatsd_size_test:
stage: integration_test
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/deb_x64:latest
tags: [ "runner:main", "size:large" ]
before_script:
# Disable global before_script
- mkdir -p $STATIC_BINARIES_DIR
- $S3_CP_CMD $S3_ARTEFACTS_URI/static/dogstatsd $STATIC_BINARIES_DIR/dogstatsd
script:
- inv -e dogstatsd.size-test --skip-build
#
# package_build
# build Agent package for deb-x64
agent_deb-x64:
stage: package_build
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/deb_x64:latest
tags: [ "runner:main", "size:2xlarge" ]
variables:
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI: /credentials
script:
# remove artifacts from previous pipelines that may come from the cache
- rm -rf $OMNIBUS_PACKAGE_DIR/*
# Artifacts and cache must live within project directory but we run omnibus in a neutral directory.
# Thus, we move the artifacts at the end in a gitlab-friendly dir.
- inv -e agent.omnibus-build --release-version "$RELEASE_VERSION" --base-dir $OMNIBUS_BASE_DIR --omnibus-s3-cache
- dpkg -c $OMNIBUS_BASE_DIR/pkg/datadog-agent*_amd64.deb
- $S3_CP_CMD $OMNIBUS_BASE_DIR/pkg/datadog-agent*_amd64.deb $S3_ARTEFACTS_URI/datadog-agent_amd64.deb
- mkdir -p $OMNIBUS_PACKAGE_DIR && cp $OMNIBUS_BASE_DIR/pkg/datadog-agent*_amd64.deb{,.metadata.json} $OMNIBUS_PACKAGE_DIR
# TODO: enabling the cache cause builds to be slower and slower on `master`. Re-enable once this is investigated/fixed
# cache:
# # cache per branch
# key: $CI_COMMIT_REF_NAME
# paths:
# - $OMNIBUS_BASE_DIR
artifacts:
expire_in: 2 weeks
paths:
- $OMNIBUS_PACKAGE_DIR
# build Agent package for deb-x64
puppy_deb-x64:
stage: package_build
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/deb_x64:latest
tags: [ "runner:main", "size:2xlarge" ]
variables:
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI: /credentials
script:
# remove artifacts from previous pipelines that may come from the cache
- rm -rf $OMNIBUS_PACKAGE_DIR/*
# Artifacts and cache must live within project directory but we run omnibus in a neutral directory.
# Thus, we move the artifacts at the end in a gitlab-friendly dir.
- inv -e agent.omnibus-build --puppy --log-level debug --release-version "$RELEASE_VERSION" --base-dir $OMNIBUS_BASE_DIR
- dpkg -c $OMNIBUS_BASE_DIR/pkg/datadog-puppy*_amd64.deb
- $S3_CP_CMD $OMNIBUS_BASE_DIR/pkg/datadog-puppy*_amd64.deb $S3_ARTEFACTS_URI/datadog-puppy_amd64.deb
- mkdir -p $OMNIBUS_PACKAGE_DIR && cp $OMNIBUS_BASE_DIR/pkg/datadog-puppy*_amd64.deb{,.metadata.json} $OMNIBUS_PACKAGE_DIR
# TODO: enabling the cache cause builds to be slower and slower on `master`. Re-enable once this is investigated/fixed
# cache:
# # cache per branch
# key: $CI_COMMIT_REF_NAME
# paths:
# - $OMNIBUS_BASE_DIR
artifacts:
expire_in: 2 weeks
paths:
- $OMNIBUS_PACKAGE_DIR
# build Agent package for rpm-x64
agent_rpm-x64:
stage: package_build
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/rpm_x64:latest
tags: [ "runner:main", "size:2xlarge" ]
variables:
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI: /credentials
script:
# remove artifacts from previous pipelines that may come from the cache
- rm -rf $OMNIBUS_PACKAGE_DIR/*
# Artifacts and cache must live within project directory but we run omnibus in a neutral directory.
# Thus, we move the artifacts at the end in a gitlab-friendly dir.
- set +x
- RPM_GPG_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.rpm_signing_private_key --with-decryption --query "Parameter.Value" --out text)
- printf -- "$RPM_GPG_KEY" | gpg --import --batch
- export RPM_SIGNING_PASSPHRASE=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.rpm_signing_key_passphrase --with-decryption --query "Parameter.Value" --out text)
- set -x
- inv -e agent.omnibus-build --release-version "$RELEASE_VERSION" --base-dir $OMNIBUS_BASE_DIR --omnibus-s3-cache
- rpm -i $OMNIBUS_BASE_DIR/pkg/*.rpm
- mkdir -p $OMNIBUS_PACKAGE_DIR && cp $OMNIBUS_BASE_DIR/pkg/*.{rpm,metadata.json} $OMNIBUS_PACKAGE_DIR
# TODO: enabling the cache cause builds to be slower and slower on `master`. Re-enable once this is investigated/fixed
# cache:
# # cache per branch
# key: $CI_COMMIT_REF_NAME
# paths:
# - $OMNIBUS_BASE_DIR
artifacts:
expire_in: 2 weeks
paths:
- $OMNIBUS_PACKAGE_DIR
# build Agent package for suse-x64
agent_suse-x64:
stage: package_build
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/suse_x64:latest
tags: [ "runner:main", "size:2xlarge" ]
variables:
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI: /credentials
script:
# remove artifacts from previous pipelines that may come from the cache
- rm -rf $OMNIBUS_PACKAGE_DIR_SUSE/*
# Artifacts and cache must live within project directory but we run omnibus in a neutral directory.
# Thus, we move the artifacts at the end in a gitlab-friendly dir.
- set +x
- RPM_GPG_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.rpm_signing_private_key --with-decryption --query "Parameter.Value" --out text)
- printf -- "$RPM_GPG_KEY" | gpg --import --batch
- export RPM_SIGNING_PASSPHRASE=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.rpm_signing_key_passphrase --with-decryption --query "Parameter.Value" --out text)
- set -x
- inv -e agent.omnibus-build --release-version "$RELEASE_VERSION" --base-dir $OMNIBUS_BASE_DIR_SUSE --omnibus-s3-cache
- mkdir -p $OMNIBUS_PACKAGE_DIR_SUSE && cp $OMNIBUS_BASE_DIR_SUSE/pkg/*.{rpm,metadata.json} $OMNIBUS_PACKAGE_DIR_SUSE
# FIXME: skip the installation step until we fix the preinst/postinst scripts in the rpm package
# to also work with SUSE11
# - rpm -i $OMNIBUS_PACKAGE_DIR_SUSE/*.rpm
# TODO: enabling the cache cause builds to be slower and slower on `master`. Re-enable once this is investigated/fixed
# cache:
# # cache per branch
# key: $CI_COMMIT_REF_NAME
# paths:
# - $OMNIBUS_BASE_DIR_SUSE
artifacts:
expire_in: 2 weeks
paths:
- $OMNIBUS_PACKAGE_DIR_SUSE
# build Agent package for Windows
build_windows_msi_x64:
## this is a weird workaround. Can't use the built-in CI_PROJECT_DIR because the path separators
## are wrong. Record the PROJECT dir with the correct path separators to be used later
before_script:
- set WIN_CI_PROJECT_DIR=%CD%
- if exist .omnibus rd /s/q .omnibus
- mkdir .omnibus\pkg
- if exist \omnibus-ruby rd /s/q \omnibus-ruby
- if exist %OMNIBUS_BASE_DIR_WIN% rd /s/q %OMNIBUS_BASE_DIR_WIN%
- if exist \opt\datadog-agent rd /s/q \opt\datadog-agent
- if exist %GOPATH%\src\github.com\DataDog\datadog-agent rd /s/q %GOPATH%\src\github.com\DataDog\datadog-agent
- mkdir %GOPATH%\src\github.com\DataDog\datadog-agent
- xcopy /q/h/e/s * %GOPATH%\src\github.com\DataDog\datadog-agent
- cd %GOPATH%\src\github.com\DataDog\datadog-agent
- inv -e deps
stage: package_build
variables:
WINDOWS_BUILDER: 'true'
CREDENTIALS_FILE_PATH: 'c:\users\gitlab\.aws\config'
tags: ["runner:windows-agent6"]
script:
# remove artifacts from previous pipelines that may come from the cache
- cd %GOPATH%\src\github.com\DataDog\datadog-agent
- inv agent.omnibus-build --release-version %RELEASE_VERSION% --omnibus-s3-cache --base-dir %OMNIBUS_BASE_DIR_WIN_OMNIBUS%
# copy the results from the build dir to here, because artifacts must be relative to the project directory
- copy %OMNIBUS_BASE_DIR_WIN%\pkg\* %WIN_CI_PROJECT_DIR%\.omnibus\pkg
artifacts:
expire_in: 2 weeks
paths:
- .omnibus/pkg
# build Agent package for android
agent_android_apk:
stage: package_build
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/android_builder:latest
tags: [ "runner:main", "size:large" ]
variables:
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI: /credentials
before_script:
- echo running android before_script
- cd $SRC_PATH
- pip install -U pip
- pip install -r requirements.txt
- inv -e deps --android
# Some Android license has changed, we have to accept the new version.
# But on top of that, there is a bug in sdkmanager not updating correctly
# the existing license, so, we have to manually accept the new license.
# https://issuetracker.google.com/issues/123054726
# The real fix will be to change the builders
- echo "24333f8a63b6825ea9c5514f83c2829b004d1fee" > "$ANDROID_HOME/licenses/android-sdk-license"
script:
# remove artifacts from previous pipelines that may come from the cache
- rm -rf $OMNIBUS_PACKAGE_DIR/*
# for now do the steps manually. Should eventually move this to an invoke
# task
- inv -e android.build
- mkdir -p $OMNIBUS_PACKAGE_DIR
- cp ./bin/agent/ddagent-*-unsigned.apk $OMNIBUS_PACKAGE_DIR
artifacts:
expire_in: 2 weeks
paths:
- $OMNIBUS_PACKAGE_DIR
# build Dogstastd package for deb-x64
dogstatsd_deb-x64:
stage: package_build
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/deb_x64:latest
tags: [ "runner:main", "size:large" ]
variables:
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI: /credentials
script:
# remove artifacts from previous pipelines that may come from the cache
- rm -rf $OMNIBUS_PACKAGE_DIR/*
# Artifacts and cache must live within project directory but we run omnibus in a neutral directory.
# Thus, we move the artifacts at the end in a gitlab-friendly dir.
- inv -e dogstatsd.omnibus-build --release-version "$RELEASE_VERSION" --base-dir $OMNIBUS_BASE_DIR --omnibus-s3-cache
- dpkg -c $OMNIBUS_BASE_DIR/pkg/datadog-dogstatsd*_amd64.deb
- $S3_CP_CMD $OMNIBUS_BASE_DIR/pkg/datadog-dogstatsd*_amd64.deb $S3_ARTEFACTS_URI/datadog-dogstatsd_amd64.deb
- mkdir -p $OMNIBUS_PACKAGE_DIR && cp $OMNIBUS_BASE_DIR/pkg/datadog-dogstatsd*_amd64.deb{,.metadata.json} $OMNIBUS_PACKAGE_DIR
# TODO: enabling the cache cause builds to be slower and slower on `master`. Re-enable once this is investigated/fixed
# cache:
# # cache per branch
# key: $CI_COMMIT_REF_NAME
# paths:
# - $OMNIBUS_BASE_DIR
artifacts:
expire_in: 2 weeks
paths:
- $OMNIBUS_PACKAGE_DIR
# build Dogstastd package for rpm-x64
dogstatsd_rpm-x64:
stage: package_build
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/rpm_x64:latest
tags: [ "runner:main", "size:large" ]
variables:
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI: /credentials
script:
# remove artifacts from previous pipelines that may come from the cache
- rm -rf $OMNIBUS_PACKAGE_DIR/*
# Artifacts and cache must live within project directory but we run omnibus
# from the GOPATH (see above). We then call `invoke` passing --base-dir,
# pointing to a gitlab-friendly location.
- set +x
- RPM_GPG_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.rpm_signing_private_key --with-decryption --query "Parameter.Value" --out text)
- printf -- "$RPM_GPG_KEY" | gpg --import --batch
- export RPM_SIGNING_PASSPHRASE=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.rpm_signing_key_passphrase --with-decryption --query "Parameter.Value" --out text)
- set -x
- inv -e dogstatsd.omnibus-build --release-version "$RELEASE_VERSION" --base-dir $OMNIBUS_BASE_DIR --omnibus-s3-cache
- rpm -i $OMNIBUS_BASE_DIR/pkg/*.rpm
- mkdir -p $OMNIBUS_PACKAGE_DIR && cp $OMNIBUS_BASE_DIR/pkg/*.{rpm,metadata.json} $OMNIBUS_PACKAGE_DIR
# TODO: enabling the cache cause builds to be slower and slower on `master`. Re-enable once this is investigated/fixed
# cache:
# # cache per branch
# key: $CI_COMMIT_REF_NAME
# paths:
# - $OMNIBUS_BASE_DIR
artifacts:
expire_in: 2 weeks
paths:
- $OMNIBUS_PACKAGE_DIR
# build Dogstastd package for rpm-x64
dogstatsd_suse-x64:
stage: package_build
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/suse_x64:latest
tags: [ "runner:main", "size:large" ]
variables:
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI: /credentials
script:
# remove artifacts from previous pipelines that may come from the cache
- rm -rf $OMNIBUS_PACKAGE_DIR/*
# Artifacts and cache must live within project directory but we run omnibus
# from the GOPATH (see above). We then call `invoke` passing --base-dir,
# pointing to a gitlab-friendly location.
- set +x
- RPM_GPG_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.rpm_signing_private_key --with-decryption --query "Parameter.Value" --out text)
- printf -- "$RPM_GPG_KEY" | gpg --import --batch
- export RPM_SIGNING_PASSPHRASE=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.rpm_signing_key_passphrase --with-decryption --query "Parameter.Value" --out text)
- set -x
- inv -e dogstatsd.omnibus-build --release-version "$RELEASE_VERSION" --base-dir $OMNIBUS_BASE_DIR_SUSE --omnibus-s3-cache
- rpm -i $OMNIBUS_BASE_DIR_SUSE/pkg/*.rpm
- mkdir -p $OMNIBUS_PACKAGE_DIR_SUSE && cp $OMNIBUS_BASE_DIR_SUSE/pkg/*.{rpm,metadata.json} $OMNIBUS_PACKAGE_DIR_SUSE
# TODO: enabling the cache cause builds to be slower and slower on `master`. Re-enable once this is investigated/fixed
# cache:
# # cache per branch
# key: $CI_COMMIT_REF_NAME
# paths:
# - $OMNIBUS_BASE_DIR_SUSE
artifacts:
expire_in: 2 weeks
paths:
- $OMNIBUS_PACKAGE_DIR_SUSE
# deploy debian packages to apt staging repo
deploy_deb_testing:
stage: testkitchen_deploy
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/deploy:latest
before_script:
- ls $OMNIBUS_PACKAGE_DIR
<<: *run_when_testkitchen_triggered
tags: [ "runner:main", "size:large" ]
script:
- source /usr/local/rvm/scripts/rvm
- rvm use 2.4
- set +x # make sure we don't output the creds to the build log
- APT_SIGNING_KEY_ID=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.apt_signing_key_id --with-decryption --query "Parameter.Value" --out text)
- APT_SIGNING_PRIVATE_KEY_PART1=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.apt_signing_private_key_part1 --with-decryption --query "Parameter.Value" --out text)
- APT_SIGNING_PRIVATE_KEY_PART2=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.apt_signing_private_key_part2 --with-decryption --query "Parameter.Value" --out text)
- APT_SIGNING_KEY_PASSPHRASE=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.apt_signing_key_passphrase --with-decryption --query "Parameter.Value" --out text)
- echo "$APT_SIGNING_KEY_ID"
- printf -- "$APT_SIGNING_PRIVATE_KEY_PART1\n$APT_SIGNING_PRIVATE_KEY_PART2\n" | gpg --import --batch
- echo "$APT_SIGNING_KEY_PASSPHRASE" | deb-s3 upload -c "pipeline-$CI_PIPELINE_ID" -b $DEB_TESTING_S3_BUCKET -a amd64 --sign=$APT_SIGNING_KEY_ID --gpg_options="--passphrase-fd 0 --pinentry-mode loopback --batch --digest-algo SHA512" --preserve_versions --visibility public $OMNIBUS_PACKAGE_DIR/*amd64.deb
- echo "$APT_SIGNING_KEY_PASSPHRASE" | deb-s3 upload -c "pipeline-$CI_PIPELINE_ID" -b $DEB_TESTING_S3_BUCKET -a x86_64 --sign=$APT_SIGNING_KEY_ID --gpg_options="--passphrase-fd 0 --pinentry-mode loopback --batch --digest-algo SHA512" --preserve_versions --visibility public $OMNIBUS_PACKAGE_DIR/*amd64.deb
# deploy rpm packages to yum staging repo
deploy_rpm_testing:
<<: *run_when_testkitchen_triggered
stage: testkitchen_deploy
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/deploy:latest
before_script:
- ls $OMNIBUS_PACKAGE_DIR
tags: [ "runner:main", "size:large" ]
script:
- source /usr/local/rvm/scripts/rvm
- rvm use 2.4
- mkdir -p ./rpmrepo/x86_64/
- aws s3 sync s3://$RPM_TESTING_S3_BUCKET/pipeline-$CI_PIPELINE_ID ./rpmrepo/
- cp $OMNIBUS_PACKAGE_DIR/*x86_64.rpm ./rpmrepo/x86_64/
- createrepo --update -v --checksum sha ./rpmrepo/x86_64
- aws s3 sync ./rpmrepo/ s3://$RPM_TESTING_S3_BUCKET/pipeline-$CI_PIPELINE_ID --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers full=id=3a6e02b08553fd157ae3fb918945dd1eaae5a1aa818940381ef07a430cf25732
# deploy rpm packages to yum staging repo
deploy_suse_rpm_testing:
<<: *run_when_testkitchen_triggered
stage: testkitchen_deploy
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/deploy:latest
before_script:
- ls $OMNIBUS_PACKAGE_DIR_SUSE
tags: [ "runner:main", "size:large" ]
script:
- source /usr/local/rvm/scripts/rvm
- rvm use 2.4
- mkdir -p ./rpmrepo/suse/x86_64/
- aws s3 sync s3://$RPM_TESTING_S3_BUCKET/suse/pipeline-$CI_PIPELINE_ID ./rpmrepo/
- cp $OMNIBUS_PACKAGE_DIR_SUSE/*x86_64.rpm ./rpmrepo/suse/x86_64/
- createrepo --update -v --checksum sha ./rpmrepo/suse/x86_64
- aws s3 sync ./rpmrepo/suse/ s3://$RPM_TESTING_S3_BUCKET/suse/pipeline-$CI_PIPELINE_ID --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers full=id=3a6e02b08553fd157ae3fb918945dd1eaae5a1aa818940381ef07a430cf25732
# deploy windows packages to our testing bucket
deploy_windows_testing:
<<: *run_when_testkitchen_triggered
stage: testkitchen_deploy
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/deploy:latest
before_script:
- ls $OMNIBUS_PACKAGE_DIR
tags: [ "runner:main", "size:large" ]
script:
- $S3_CP_CMD --recursive --exclude "*" --include "*.msi" $OMNIBUS_PACKAGE_DIR s3://$WINDOWS_TESTING_S3_BUCKET --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers full=id=3a6e02b08553fd157ae3fb918945dd1eaae5a1aa818940381ef07a430cf25732
# run dd-agent-testing on windows
kitchen_windows:
stage: testkitchen_testing
allow_failure: true
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/dd-agent-testing:latest
<<: *run_when_testkitchen_triggered
before_script:
- rsync -azr --delete ./ $SRC_PATH
tags: [ "runner:main", "size:large" ]
script:
- cd $CI_PROJECT_DIR
- cd $DD_AGENT_TESTING_DIR
- mkdir $CI_PROJECT_DIR/kitchen_logs
- ln -s $CI_PROJECT_DIR/kitchen_logs $DD_AGENT_TESTING_DIR/.kitchen
- export TEST_PLATFORMS="win2012,MicrosoftWindowsServer:WindowsServer:2012-Datacenter:3.127.20181122"
- export TEST_PLATFORMS="$TEST_PLATFORMS|win2012r2,MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:4.127.20181125"
- export TEST_PLATFORMS="$TEST_PLATFORMS|win2016,MicrosoftWindowsServer:WindowsServer:2016-Datacenter:2016.127.20181122"
- export TEST_PLATFORMS="$TEST_PLATFORMS|win2019,MicrosoftWindowsServer:WindowsServer:2019-Datacenter:2019.0.20181122"
- bash -l tasks/run-test-kitchen.sh
artifacts:
expire_in: 2 weeks
when: always
paths:
- $CI_PROJECT_DIR/kitchen_logs
kitchen_windows_installer:
stage: testkitchen_testing
allow_failure: true
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/dd-agent-testing:latest
<<: *run_when_testkitchen_triggered
before_script:
- rsync -azr --delete ./ $SRC_PATH
tags: [ "runner:main", "size:large" ]
script:
- cd $CI_PROJECT_DIR
- cd $DD_AGENT_TESTING_DIR
- mkdir $CI_PROJECT_DIR/kitchen_logs
- ln -s $CI_PROJECT_DIR/kitchen_logs $DD_AGENT_TESTING_DIR/.kitchen
- export TEST_PLATFORMS="win2012,MicrosoftWindowsServer:WindowsServer:2012-Datacenter:3.127.20181122"
- bash -l tasks/run-test-kitchen.sh windows-install-test
artifacts:
expire_in: 2 weeks
when: always
paths:
- $CI_PROJECT_DIR/kitchen_logs
# run dd-agent-testing on centos
kitchen_centos:
stage: testkitchen_testing
allow_failure: false
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/dd-agent-testing:latest
<<: *run_when_testkitchen_triggered
before_script:
- rsync -azr --delete ./ $SRC_PATH
tags: [ "runner:main", "size:large" ]
script:
- cd $CI_PROJECT_DIR
- cd $DD_AGENT_TESTING_DIR
- mkdir $CI_PROJECT_DIR/kitchen_logs
- ln -s $CI_PROJECT_DIR/kitchen_logs $DD_AGENT_TESTING_DIR/.kitchen
- export TEST_PLATFORMS="centos-74,OpenLogic:CentOS:7.4:7.4.20171110"
- bash -l tasks/run-test-kitchen.sh
artifacts:
expire_in: 2 weeks
when: always
paths:
- $CI_PROJECT_DIR/kitchen_logs
# run dd-agent-testing on ubuntu (FIXME: Allowed to fail until we resolve the issue with apt locks/azure agent)
kitchen_ubuntu:
stage: testkitchen_testing
allow_failure: true
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/dd-agent-testing:latest
<<: *run_when_testkitchen_triggered
before_script:
- rsync -azr --delete ./ $SRC_PATH
tags: [ "runner:main", "size:large" ]
script:
- cd $CI_PROJECT_DIR
- cd $DD_AGENT_TESTING_DIR
- mkdir $CI_PROJECT_DIR/kitchen_logs
- ln -s $CI_PROJECT_DIR/kitchen_logs $DD_AGENT_TESTING_DIR/.kitchen
- export TEST_PLATFORMS="ubuntu-14-04,Canonical:UbuntuServer:14.04.5-LTS:14.04.201803080"
- export TEST_PLATFORMS="$TEST_PLATFORMS|ubuntu-16-04,Canonical:UbuntuServer:16.04.0-LTS:16.04.201802220"
- bash -l tasks/run-test-kitchen.sh
artifacts:
expire_in: 2 weeks
when: always
paths:
- $CI_PROJECT_DIR/kitchen_logs
# run dd-agent-testing on suse
kitchen_suse:
stage: testkitchen_testing
allow_failure: false
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/dd-agent-testing:latest
<<: *run_when_testkitchen_triggered
before_script:
- rsync -azr --delete ./ $SRC_PATH
tags: [ "runner:main", "size:large" ]
script:
- cd $CI_PROJECT_DIR
- cd $DD_AGENT_TESTING_DIR
- mkdir $CI_PROJECT_DIR/kitchen_logs
- ln -s $CI_PROJECT_DIR/kitchen_logs $DD_AGENT_TESTING_DIR/.kitchen
- export TEST_PLATFORMS="sles-12,SUSE:SLES:12-SP3:2018.09.04"
- bash -l tasks/run-test-kitchen.sh
artifacts:
expire_in: 2 weeks
when: always
paths:
- $CI_PROJECT_DIR/kitchen_logs
# run dd-agent-testing on debian (FIXME: Allowed to fail until we resolve the issue with apt locks/azure agent)
kitchen_debian:
stage: testkitchen_testing
allow_failure: true
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/dd-agent-testing:latest
<<: *run_when_testkitchen_triggered
before_script:
- rsync -azr --delete ./ $SRC_PATH
tags: [ "runner:main", "size:large" ]
script:
- cd $CI_PROJECT_DIR
- cd $DD_AGENT_TESTING_DIR
- mkdir $CI_PROJECT_DIR/kitchen_logs
- ln -s $CI_PROJECT_DIR/kitchen_logs $DD_AGENT_TESTING_DIR/.kitchen
- export TEST_PLATFORMS="debian-8,credativ:Debian:8:8.0.201803130"
- bash -l tasks/run-test-kitchen.sh
artifacts:
expire_in: 2 weeks
when: always
paths:
- $CI_PROJECT_DIR/kitchen_logs
# run dd-agent-testing
testkitchen_cleanup_s3:
stage: testkitchen_cleanup
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/deploy:latest
<<: *run_when_testkitchen_triggered
tags: [ "runner:main", "size:large" ]
before_script:
- ls
# even if this fails, it shouldn't block the pipeline.
allow_failure: true
when: always
script:
- aws s3 rm s3://$DEB_TESTING_S3_BUCKET/dists/pipeline-$CI_PIPELINE_ID --recursive
- aws s3 rm s3://$RPM_TESTING_S3_BUCKET/pipeline-$CI_PIPELINE_ID --recursive
- aws s3 rm s3://$RPM_TESTING_S3_BUCKET/suse/pipeline-$CI_PIPELINE_ID --recursive
- aws s3 rm s3://$WINDOWS_TESTING_S3_BUCKET --recursive
- cd $OMNIBUS_PACKAGE_DIR
- for deb in $(ls *amd64.deb); do aws s3 rm s3://$DEB_TESTING_S3_BUCKET/pool/d/da/$deb --recursive; done
# run dd-agent-testing
testkitchen_cleanup_azure:
stage: testkitchen_cleanup
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/dd-agent-testing:latest
<<: *run_when_testkitchen_triggered
# even if this fails, it shouldn't block the pipeline.
allow_failure: true
when: always
tags: [ "runner:main", "size:large" ]
before_script:
- rsync -azr --delete ./ $SRC_PATH
script:
- cd $DD_AGENT_TESTING_DIR
- bash -l tasks/clean.sh
#
# image_build
#
# docker build must run with DOCKER_CONTENT_TRUST to
# enable signature check of the base images
#
.docker_build_job_definition: &docker_build_job_definition
stage: image_build
tags: [ "runner:docker", "size:large" ]
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/docker-notary:0.6.1
before_script: [ "# noop" ] # Override top level entry
dependencies: [] # Don't download Gitlab artifacts
script:
- aws s3 sync --only-show-errors "s3://dd-ci-artefacts-build-stable/datadog-agent/$CI_PIPELINE_ID" $BUILD_CONTEXT
- TAG_SUFFIX=${TAG_SUFFIX:-}
- BUILD_ARG=${BUILD_ARG:-}
- DOCKER_CONTENT_TRUST=1 docker build $BUILD_ARG --pull --tag $IMAGE:v$CI_PIPELINE_ID-${CI_COMMIT_SHA:0:7}$TAG_SUFFIX $BUILD_CONTEXT
- docker push $IMAGE:v$CI_PIPELINE_ID-${CI_COMMIT_SHA:0:7}$TAG_SUFFIX
# build the agent6 image
build_agent6:
<<: *docker_build_job_definition
variables:
IMAGE: &agent_ecr 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent/agent
BUILD_CONTEXT: Dockerfiles/agent
# build the agent6 jmx image
build_agent6_jmx:
<<: *docker_build_job_definition
variables:
IMAGE: &agent_ecr 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent/agent
BUILD_CONTEXT: Dockerfiles/agent
TAG_SUFFIX: -jmx
BUILD_ARG: --build-arg WITH_JMX=true
# build the cluster-agent image
build_cluster_agent:
<<: *docker_build_job_definition
variables:
IMAGE: &cluster-agent_ecr 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent/cluster-agent
BUILD_CONTEXT: Dockerfiles/cluster-agent
# build the dogstatsd image
build_dogstatsd:
<<: *docker_build_job_definition
variables:
IMAGE: &dogstatsd_ecr 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent/dogstatsd
BUILD_CONTEXT: Dockerfiles/dogstatsd/alpine
#
# Docker dev image deployments
#
twistlock_scan:
stage: image_deploy
tags: [ "runner:docker", "size:large" ]
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/twistlock-cli:2.5.121
dependencies: [] # Don't download Gitlab artefacts
allow_failure: true # Don't block the pipeline
variables:
SRC_AGENT: *agent_ecr
SRC_DSD: *dogstatsd_ecr
SRC_DCA: *cluster-agent_ecr
before_script:
- export SRC_TAG=v$CI_PIPELINE_ID-${CI_COMMIT_SHA:0:7}
- export DOCKER_CLIENT_ADDRESS=$DOCKER_HOST
- TWISTLOCK_PASS=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.twistlock_password --with-decryption --query "Parameter.Value" --out text)
- scan () { echo -e "\n==== Scanning $1 ====\n"; docker pull $1 > /dev/null; /twistcli images scan --address="$TWISTLOCK_URL" --user="$TWISTLOCK_USER" --password="$TWISTLOCK_PASS" --vulnerability-threshold=$THRESHOLD --details $1; }
script:
- scan ${SRC_AGENT}:${SRC_TAG}
- scan ${SRC_AGENT}:${SRC_TAG}-jmx
- scan ${SRC_DSD}:${SRC_TAG}
- scan ${SRC_DCA}:${SRC_TAG}
.docker_tag_job_definition: &docker_tag_job_definition
stage: image_deploy
tags: [ "runner:docker", "size:large" ]
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/docker-notary:0.6.1
before_script:
- export SRC_TAG=v$CI_PIPELINE_ID-${CI_COMMIT_SHA:0:7}
- DOCKER_REGISTRY_LOGIN=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.$DOCKER_REGISTRY_LOGIN_SSM_KEY --with-decryption --query "Parameter.Value" --out text)
- aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.$DOCKER_REGISTRY_PWD_SSM_KEY --with-decryption --query "Parameter.Value" --out text | docker login --username "$DOCKER_REGISTRY_LOGIN" --password-stdin "$DOCKER_REGISTRY_URL"
- pip install -r requirements.txt
- if [[ -z "$DELEGATION_PASS_SSM_KEY" ]]; then echo "No signing key set"; exit 0; fi
- echo "Importing delegation signing key"
- export DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.$DELEGATION_PASS_SSM_KEY --with-decryption --query "Parameter.Value" --out text)
- aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.$DELEGATION_KEY_SSM_KEY --with-decryption --query "Parameter.Value" --out text > /tmp/docker.key
- notary -d ~/.docker/trust key import /tmp/docker.key; rm /tmp/docker.key
dependencies: [] # Don't download Gitlab artefacts
.docker_hub_variables: &docker_hub_variables
DOCKER_REGISTRY_LOGIN_SSM_KEY: docker_hub_login
DOCKER_REGISTRY_PWD_SSM_KEY: docker_hub_pwd
DELEGATION_KEY_SSM_KEY: docker_hub_signing_key
DELEGATION_PASS_SSM_KEY: docker_hub_signing_pass
DOCKER_REGISTRY_URL: docker.io
SRC_AGENT: *agent_ecr
SRC_DSD: *dogstatsd_ecr
SRC_DCA: *cluster-agent_ecr
.quay_variables: &quay_variables
<<: *docker_hub_variables
DOCKER_REGISTRY_LOGIN_SSM_KEY: quay_login
DOCKER_REGISTRY_PWD_SSM_KEY: quay_pwd
DOCKER_REGISTRY_URL: quay.io
dev_branch_docker_hub:
<<: *docker_tag_job_definition
when: manual
except:
- master
variables:
<<: *docker_hub_variables
script:
- inv -e docker.publish --signed-push ${SRC_AGENT}:${SRC_TAG} datadog/agent-dev:${CI_COMMIT_REF_SLUG}
- inv -e docker.publish --signed-push ${SRC_AGENT}:${SRC_TAG}-jmx datadog/agent-dev:${CI_COMMIT_REF_SLUG}-jmx
- inv -e docker.publish --signed-push ${SRC_DSD}:${SRC_TAG} datadog/dogstatsd-dev:${CI_COMMIT_REF_SLUG}
dev_master_docker_hub:
<<: *docker_tag_job_definition
only:
- master
variables:
<<: *docker_hub_variables
script:
- inv -e docker.publish --signed-push ${SRC_AGENT}:${SRC_TAG} datadog/agent-dev:master
- inv -e docker.publish --signed-push ${SRC_AGENT}:${SRC_TAG}-jmx datadog/agent-dev:master-jmx
- inv -e docker.publish --signed-push ${SRC_DSD}:${SRC_TAG} datadog/dogstatsd-dev:master
dca_dev_branch_docker_hub:
<<: *docker_tag_job_definition
when: manual
except:
- master
variables:
<<: *docker_hub_variables
script:
- inv -e docker.publish --signed-push ${SRC_DCA}:${SRC_TAG} datadog/cluster-agent-dev:${CI_COMMIT_REF_SLUG}
dca_dev_master_docker_hub:
<<: *docker_tag_job_definition
only:
- master
variables:
<<: *docker_hub_variables
script:
- inv -e docker.publish --signed-push ${SRC_DCA}:${SRC_TAG} datadog/cluster-agent-dev:master
# deploys to quay
# docker images are mirrored on quay.io
# to run security scans on them
dev_master_quay:
<<: *docker_tag_job_definition
<<: *run_when_triggered_on_nightly
variables:
<<: *quay_variables
script:
- inv -e docker.publish ${SRC_AGENT}:${SRC_TAG} quay.io/datawhale/agent-dev:master
- inv -e docker.publish ${SRC_AGENT}:${SRC_TAG}-jmx quay.io/datawhale/agent-dev:master-jmx
- inv -e docker.publish ${SRC_DSD}:${SRC_TAG} quay.io/datawhale/dogstatsd-dev:master
#
# Check Deploy
#
# Check that the current version hasn't already been deployed (we don't want to
# overwrite a public package). To update an erroneous package, first remove it
# from our S3 bucket.
check_already_deployed_version:
<<: *run_when_triggered
stage: check_deploy
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/deploy:latest
before_script:
- ls $OMNIBUS_PACKAGE_DIR
tags: [ "runner:main", "size:large" ]
script:
- cd $OMNIBUS_PACKAGE_DIR && /deploy_scripts/fail_deb_is_pkg_already_exists.sh
# If we trigger a build only pipeline we stop here.
check_if_build_only:
<<: *run_when_triggered
stage: check_deploy
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/deploy:latest
before_script:
- ls $OMNIBUS_PACKAGE_DIR
tags: [ "runner:main", "size:large" ]
script:
- if [ "$DEB_RPM_BUCKET_BRANCH" == "none" ]; then echo "Stopping pipeline"; exit 1; fi
#
# deploy
#
# deploy debian packages to apt staging repo
deploy_deb:
<<: *run_when_triggered
stage: deploy
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/deploy:latest
before_script:
- ls $OMNIBUS_PACKAGE_DIR
tags: [ "runner:main", "size:large" ]
script:
# We first check that the current version hasn't already been deployed
# (same as the check_already_deployed_version). We do this twice to mitigate
# races and issues with retries while failing early if there is an issue.