forked from signalfx/splunk-otel-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
1410 lines (1338 loc) · 41.9 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
default:
image: '${DOCKER_CICD_REPO}/ci-container/debian-buster:3.1.1'
variables:
WIN_2019_BASE_IMAGE: mcr.microsoft.com/windows/servercore:ltsc2019
WIN_2022_BASE_IMAGE: mcr.microsoft.com/windows/servercore:ltsc2022
stages:
- update-deps
- sast-oss-scan
- build
- sign-binaries
- package
- sign-packages
- release
- docker-manifest-release
- xray-scan
- github-release
include:
- project: 'prodsec/scp-scanning/gitlab-checkmarx'
ref: latest
file: '/templates/.sast_scan.yml'
- project: 'ci-cd/templates'
ref: master
file:
- '/prodsec/.oss-scan.yml'
- '/prodsec/.binary-scan.yml'
- '/prodsec/.container-scan.yml'
- project: 'core-ee/signing/api-integration'
ref: develop
file: '/templates/.sign-client.yml'
semgrep:
stage: sast-oss-scan
extends: .sast_scan
retry: 2
variables:
SAST_SCANNER: "Semgrep"
SEMGREP_EXCLUDE: "examples,internal/buildscripts,tests,*_test.go,cmd/otelcol/Dockerfile.windows,deployments/ansible/molecule"
alert_mode: "policy"
after_script:
- echo "Check results at $CI_PIPELINE_URL/security"
only:
- main
- schedules
needs: []
dependencies: []
fossa:
extends: .oss-scan
stage: sast-oss-scan
only:
- main
- schedules
needs: []
dependencies: []
variables:
jira_automation: "true"
# allow_failure: false
.docker-reader-role: &docker-reader-role |
creds-helper init
eval $(creds-helper docker --eval "artifactory:v2/cloud/role/docker-reader-role")
.docker-releaser-role: &docker-releaser-role |
creds-helper init
eval $(creds-helper docker --eval "artifactory:v2/cloud/role/docker-releaser-role")
.docker-test-releaser-role: &docker-test-releaser-role |
creds-helper init
eval $(creds-helper docker --eval "artifactory:v2/cloud/role/docker-test-releaser-role")
.generic-releaser-role: &generic-releaser-role |
creds-helper init
eval $(creds-helper artifactory --eval "artifactory:v2/cloud/role/generic-releaser-role")
.generic-test-releaser-role: &generic-test-releaser-role |
creds-helper init
eval $(creds-helper artifactory --eval "artifactory:v2/cloud/role/generic-test-releaser-role")
.sign-docker:
extends: .trigger-filter
retry: 2
id_tokens: # http://go/gitlab-17
CI_JOB_JWT:
aud:
- $CICD_VAULT_ADDR
- $SIGNING_PRD_URL
script:
- docker login -u $CIRCLECI_QUAY_USERNAME -p $CIRCLECI_QUAY_PASSWORD quay.io
- echo "listing images to be signed"
- cat tags_to_sign
- cat tags_to_sign | xargs -L1 artifact-ci sign docker
.get-artifactory-stage: &get-artifactory-stage
- |
set -ex
export STAGE="test"
if [[ "${CI_COMMIT_TAG:-}" =~ beta ]]; then
export STAGE="beta"
elif [[ "${CI_COMMIT_TAG:-}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
export STAGE="release"
fi
.aws-releaser-role: &aws-releaser-role |
creds-helper init
eval $(creds-helper aws --eval "aws:v1/o11y-infra/role/o11y_gdi_otel_releaser_role")
.trigger-filter:
only:
variables:
- $CI_COMMIT_BRANCH == "main"
- $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+.*/
except:
- schedules
.deploy-release:
image: '${DOCKER_CICD_REPO}/ci-container/python-3.9:1.8.0'
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
key:
files:
- internal/buildscripts/packaging/release/requirements.txt
paths:
- .cache/pip
retry: 2
id_tokens: # http://go/gitlab-17
CI_JOB_JWT:
aud: $CICD_VAULT_ADDR
script:
- *get-artifactory-stage
- *aws-releaser-role
- pip3 install -r internal/buildscripts/packaging/release/requirements.txt
- |
if [ -n "${PATHS:-}" ]; then
for path in $PATHS; do
if [ ! -f "$path" ]; then
echo "$path not found!"
exit 1
fi
python3 internal/buildscripts/packaging/release/release.py --force --stage=${STAGE} --path=$path ${OPTIONS:-}
done
elif [ -n "${INSTALLERS:-}" ]; then
python3 internal/buildscripts/packaging/release/release.py --force --installers ${OPTIONS:-}
else
echo "Either the PATHS or INSTALLERS env var must be defined!" >&2
exit 1
fi
.go-cache:
image: '${DOCKER_HUB_REPO}/golang:1.22.7'
variables:
GOPATH: "$CI_PROJECT_DIR/.go"
before_script:
- mkdir -p $GOPATH
- make install-tools
- export PATH=$GOPATH/bin:$PATH
cache:
key:
files:
- go.mod
- go.sum
paths:
- .go/pkg/mod
- .go/bin
# Upload deb/rpm package for the main branch to the generic-test artifactory repo for xray scanning
.xray-publish-package: &xray-publish-package
- if [[ ! "${PKG_TYPE:-}" =~ ^deb|rpm$ ]]; then exit 0; fi
- if [ "$CI_COMMIT_BRANCH" != "main" ]; then touch xray_artifact_path; exit 0; fi
- *generic-test-releaser-role
- package=$(find ./dist -name "*.${PKG_TYPE}")
- if [[ -z "$package" || ! -f "$package" ]]; then echo "Failed to find $PKG_TYPE package"; exit 1; fi
- target="splunk-otel-collector/${CI_COMMIT_SHA}/$(basename $package)"
- artifact-ci publish generic -o $package generic-test/${target}
- |
# Xray needs the local repo path to the artifact.
# Determine the local repo after uploading to the virtual repo.
local_repo=""
for repo in "generic-test-east-local" "generic-test-west-local"; do
if curl -LIf -u $ARTIFACTORY_AUTHORIZATION ${ARTIFACTORY_BASE_URL}/${repo}/${target}; then
local_repo=$repo
break
fi
done
if [ -z "$local_repo" ]; then
echo "Failed to determine local repo for $target"
exit 1
fi
- echo "${ARTIFACTORY_BASE_URL}/${local_repo}/${target}" | tee xray_artifact_path
.xray-scan-package:
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_BRANCH == "main"
extends: .binary-scan
stage: xray-scan
variables:
create_jira: "true"
before_script:
- export ARTIFACT_PATH=$(cat xray_artifact_path)
- echo $ARTIFACT_PATH
update-otel-deps:
only:
- schedules
extends: .go-cache
stage: update-deps
needs: []
dependencies: []
script:
- .gitlab/install-gh-cli.sh
- .gitlab/update-otel-deps.sh latest create-pull-request/update-deps
update-otel-deps-nightly:
only:
- schedules
extends: .go-cache
stage: update-deps
needs: []
dependencies: []
script:
- .gitlab/install-gh-cli.sh
- .gitlab/update-otel-deps.sh main create-pull-request/update-deps-nightly
update-openjdk:
only:
- schedules
stage: update-deps
needs: []
dependencies: []
script:
- .gitlab/install-gh-cli.sh
- .gitlab/update-openjdk.sh
update-javaagent:
only:
- schedules
stage: update-deps
needs: []
dependencies: []
script:
- .gitlab/install-gh-cli.sh
- .gitlab/update-javaagent.sh
update-jmx-metrics-gatherer:
only:
- schedules
stage: update-deps
needs: []
dependencies: []
script:
- .gitlab/install-gh-cli.sh
- .gitlab/update-jmx-metrics-gatherer.sh
update-nodejs-agent:
only:
- schedules
stage: update-deps
needs: []
dependencies: []
script:
- .gitlab/install-gh-cli.sh
- .gitlab/update-nodejs-agent.sh
update-dotnet-agent:
only:
- schedules
stage: update-deps
needs: []
dependencies: []
script:
- .gitlab/install-gh-cli.sh
- .gitlab/update-dotnet-agent.sh
tidy-dependabot-pr:
rules:
- if: $CI_COMMIT_BRANCH =~ /^dependabot\/go_modules\/.*/ && $CI_COMMIT_AUTHOR =~ /^dependabot.*/
extends: .go-cache
stage: update-deps
needs: []
dependencies: []
script:
- .gitlab/install-gh-cli.sh
- .gitlab/tidy-dependabot-pr.sh
compile:
extends:
- .trigger-filter
- .go-cache
stage: build
needs: []
parallel:
matrix:
- TARGET: [binaries-darwin_amd64, binaries-darwin_arm64, binaries-linux_amd64, binaries-linux_arm64, binaries-windows_amd64, binaries-linux_ppc64le]
script:
- |
if [[ -n "${CI_COMMIT_TAG:-}" ]]; then
make $TARGET VERSION=${CI_COMMIT_TAG}
else
make $TARGET
fi
after_script:
- if [ -e bin/otelcol ]; then rm -f bin/otelcol; fi # remove the symlink
- if [ -e bin/migratecheckpoint ]; then rm -f bin/migratecheckpoint; fi # remove the symlink
artifacts:
paths:
- bin/otelcol_*
- bin/migratecheckpoint_*
libsplunk:
extends: .trigger-filter
stage: build
needs: []
retry: 2
parallel:
matrix:
- ARCH: ["amd64", "arm64"]
id_tokens: # http://go/gitlab-17
CI_JOB_JWT:
aud: $CICD_VAULT_ADDR
script:
- *docker-reader-role
- make -C instrumentation dist ARCH=${ARCH} DOCKER_REPO=${DOCKER_HUB_REPO}
artifacts:
paths:
- instrumentation/dist/libsplunk_*.so
agent-bundle-linux:
rules:
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+.*/
- if: $CI_PIPELINE_SOURCE == "schedule"
stage: build
needs: []
retry: 2
resource_group: agent-bundle-linux-${ARCH}
parallel:
matrix:
- ARCH: amd64
TAG: main
- ARCH: arm64
TAG: arm
tags:
- $TAG
id_tokens: # http://go/gitlab-17
CI_JOB_JWT:
aud: $CICD_VAULT_ADDR
script:
- *docker-reader-role
- docker login -u $CIRCLECI_QUAY_USERNAME -p $CIRCLECI_QUAY_PASSWORD quay.io
- PUSH_CACHE=yes make -C internal/signalfx-agent/bundle agent-bundle-linux ARCH=${ARCH} DOCKER_REPO=${DOCKER_HUB_REPO}
artifacts:
paths:
- dist/agent-bundle_linux_${ARCH}.tar.gz
agent-bundle-windows:
extends: .trigger-filter
stage: build
needs: []
tags:
- splunk-otel-collector-windows
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
key:
files:
- internal/signalfx-agent/bundle/collectd-plugins.yaml
- internal/signalfx-agent/bundle/scripts/requirements.txt
paths:
- .cache/pip
script:
- ./internal/signalfx-agent/bundle/scripts/windows/make.ps1 bundle
artifacts:
paths:
- dist/agent-bundle_windows_amd64.zip
.instrumentation-deb-rpm:
extends: .trigger-filter
stage: package
needs:
- libsplunk
parallel:
matrix:
- ARCH: [amd64, arm64]
id_tokens: # http://go/gitlab-17
CI_JOB_JWT:
aud: $CICD_VAULT_ADDR
before_script:
- ./instrumentation/packaging/fpm/install-deps.sh
script:
- ./instrumentation/packaging/fpm/${PKG_TYPE}/build.sh "${CI_COMMIT_TAG:-}" "$ARCH" "./dist"
- *xray-publish-package
instrumentation-deb:
extends: .instrumentation-deb-rpm
variables:
PKG_TYPE: deb
artifacts:
paths:
- dist/*.deb
- xray_artifact_path
xray-instrumentation-deb:
extends: .xray-scan-package
needs:
- instrumentation-deb
parallel:
matrix:
- ARCH: [amd64, arm64]
instrumentation-rpm:
extends: .instrumentation-deb-rpm
variables:
PKG_TYPE: rpm
artifacts:
paths:
- dist/*.rpm
- xray_artifact_path
xray-instrumentation-rpm:
extends: .xray-scan-package
needs:
- instrumentation-rpm
parallel:
matrix:
- ARCH: [amd64, arm64]
sign-exe:
extends:
- .trigger-filter
- .submit-signing-request
stage: sign-binaries
retry: 2
needs:
- compile
parallel:
matrix:
- TARGET: [otelcol]
variables:
ARTIFACT: bin/${TARGET}_windows_amd64.exe
SIGN_TYPE: WIN
DOWNLOAD_DIR: dist/signed
artifacts:
paths:
- dist/signed/${TARGET}_windows_amd64.exe
sign-osx:
extends:
- .trigger-filter
- .submit-signing-request
stage: sign-binaries
retry: 2
needs:
- compile
parallel:
matrix:
- ARCH: [amd64, arm64]
variables:
ARTIFACT: bin/packages.tar.gz
SIGN_TYPE: OSX
OPTIONS: archive
DOWNLOAD_DIR: dist/signed
before_script:
- mkdir -p dist
- pushd bin && tar -czvf packages.tar.gz otelcol_darwin_${ARCH} && popd
after_script:
- tar -xzvf dist/signed/packages.tar.gz -C dist/signed/
- rm dist/signed/packages.tar.gz
artifacts:
paths:
- dist/signed/otelcol_darwin_${ARCH}
.build-tar-deb-rpm:
stage: package
needs:
- compile
- agent-bundle-linux
parallel:
matrix:
- ARCH: [amd64, arm64]
id_tokens: # http://go/gitlab-17
CI_JOB_JWT:
aud: $CICD_VAULT_ADDR
before_script:
- ./internal/buildscripts/packaging/fpm/install-deps.sh
script:
- ./internal/buildscripts/packaging/fpm/${PKG_TYPE}/build.sh "${CI_COMMIT_TAG:-}" "$ARCH" "./dist"
- *xray-publish-package
build-deb:
extends:
- .trigger-filter
- .build-tar-deb-rpm
variables:
PKG_TYPE: deb
artifacts:
paths:
- dist/*.deb
- xray_artifact_path
xray-collector-deb:
extends: .xray-scan-package
needs:
- build-deb
parallel:
matrix:
- ARCH: [amd64, arm64]
build-rpm:
extends:
- .trigger-filter
- .build-tar-deb-rpm
variables:
PKG_TYPE: rpm
artifacts:
paths:
- dist/*.rpm
- xray_artifact_path
xray-collector-rpm:
extends: .xray-scan-package
needs:
- build-rpm
parallel:
matrix:
- ARCH: [amd64, arm64]
build-tar:
extends:
- .trigger-filter
- .build-tar-deb-rpm
variables:
PKG_TYPE: tar
artifacts:
paths:
- dist/splunk-otel-collector*.tar.gz
build-msi:
extends: .trigger-filter
stage: package
needs:
- sign-exe
- agent-bundle-windows
- msi-custom-actions-package
before_script:
# build the MSI with the signed exe
- mkdir -p bin
- cp -f dist/signed/otelcol_windows_amd64.exe bin/otelcol_windows_amd64.exe
id_tokens: # http://go/gitlab-17
CI_JOB_JWT:
aud: $CICD_VAULT_ADDR
script:
- *docker-reader-role
- make msi SKIP_COMPILE=true VERSION=${CI_COMMIT_TAG:-} DOCKER_REPO=${DOCKER_HUB_REPO}
artifacts:
paths:
- dist/*.msi
msi-custom-actions-package:
extends: .trigger-filter
stage: package
needs:
- job: msi-custom-actions-assemblies
artifacts: true
tags:
- splunk-otel-collector-windows
script:
- $WixPath = "${Env:ProgramFiles(x86)}\WiX Toolset v3.14"
- $sfxcaDll = "${WixPath}\SDK\x64\sfxca.dll"
- $Env:PATH = "${WixPath}\SDK;" + $Env:PATH
- $customActionDir = "${PWD}\internal\buildscripts\packaging\msi\SplunkCustomActions"
- $customActionBinDir = "${customActionDir}\bin\Release"
- MakeSfxCA.exe "${customActionBinDir}\SplunkCustomActions.CA.dll" `
"${sfxcaDll}" `
"${customActionBinDir}\SplunkCustomActions.dll" `
"${customActionBinDir}\Microsoft.Deployment.WindowsInstaller.dll" `
"${customActionDir}\src\CustomAction.config"
artifacts:
paths:
- internal/buildscripts/packaging/msi/SplunkCustomActions/bin/Release/SplunkCustomActions.CA.dll
msi-custom-actions-assemblies:
extends: .trigger-filter
image: 'mcr.microsoft.com/dotnet/sdk:8.0'
stage: package
needs: []
dependencies: []
script:
- pushd ./internal/buildscripts/packaging/msi/SplunkCustomActions/
- dotnet publish ./src/SplunkCustomActions.csproj -c Release -o ./bin/Release
- popd
artifacts:
name: msi-custom-actions-assemblies
paths:
- internal/buildscripts/packaging/msi/SplunkCustomActions/bin/Release/*
sign-debs:
extends:
- .trigger-filter
- .submit-signing-request
stage: sign-packages
retry: 2
needs:
- build-deb
- instrumentation-deb
variables:
ARTIFACT: dist/packages.tar.gz
SIGN_TYPE: DEB
OPTIONS: archive
DOWNLOAD_DIR: dist/signed
before_script:
- pushd dist && tar -czvf packages.tar.gz *.deb && popd
after_script:
- tar -xzvf dist/signed/packages.tar.gz -C dist/signed/
- rm dist/signed/packages.tar.gz
artifacts:
paths:
- dist/signed/*.deb
sign-rpms:
extends:
- .trigger-filter
- .submit-signing-request
stage: sign-packages
retry: 2
needs:
- build-rpm
- instrumentation-rpm
variables:
ARTIFACT: dist/packages.tar.gz
SIGN_TYPE: RPM
OPTIONS: archive
DOWNLOAD_DIR: dist/signed
before_script:
- pushd dist && tar -czvf packages.tar.gz *.rpm && popd
after_script:
- tar -xzvf dist/signed/packages.tar.gz -C dist/signed/
- rm dist/signed/packages.tar.gz
artifacts:
paths:
- dist/signed/*.rpm
sign-tar:
extends:
- .trigger-filter
- .submit-signing-request
stage: sign-packages
retry: 2
needs:
- build-tar
variables:
ARTIFACT: dist/packages.tar.gz
SIGN_TYPE: GPG
OPTIONS: archive
DOWNLOAD_DIR: dist/signed
before_script:
- pushd dist && tar -czvf packages.tar.gz splunk-otel-collector*.tar.gz && popd
after_script:
- tar -xzvf dist/signed/packages.tar.gz -C dist/signed/
- mv dist/splunk-otel-collector*.tar.gz dist/signed/
- rm dist/signed/packages.tar.gz
artifacts:
paths:
- dist/signed/*.tar.gz
- dist/signed/*.tar.gz.asc
sign-msi:
extends:
- .trigger-filter
- .submit-signing-request
stage: sign-packages
retry: 2
needs:
- build-msi
variables:
ARTIFACT: dist/packages.tar.gz
SIGN_TYPE: WIN
OPTIONS: archive
DOWNLOAD_DIR: dist/signed
before_script:
- pushd dist && tar -czvf packages.tar.gz *.msi && popd
after_script:
- tar -xzvf dist/signed/packages.tar.gz -C dist/signed/
- rm dist/signed/packages.tar.gz
artifacts:
paths:
- dist/signed/*.msi
sign-agent-bundles:
extends:
- .trigger-filter
- .submit-signing-request
stage: sign-packages
retry: 2
needs:
- agent-bundle-linux
- agent-bundle-windows
variables:
ARTIFACT: dist/packages.tar.gz
SIGN_TYPE: GPG
OPTIONS: archive
DOWNLOAD_DIR: dist/signed
before_script:
- pushd dist && tar -czvf packages.tar.gz *.tar.gz *.zip && popd
after_script:
- tar -xzvf dist/signed/packages.tar.gz -C dist/signed/
- mv dist/*.tar.gz dist/signed/
- mv dist/*.zip dist/signed/
- rm dist/signed/packages.tar.gz
artifacts:
paths:
- dist/signed/*.tar.gz
- dist/signed/*.tar.gz.asc
- dist/signed/*.zip
- dist/signed/*.zip.asc
sign-ps-installer:
extends:
- .trigger-filter
- .submit-signing-request
stage: sign-packages
retry: 2
dependencies: []
variables:
ARTIFACT: dist/install.ps1
SIGN_TYPE: WIN
DOWNLOAD_DIR: dist/signed
before_script:
- mkdir -p dist
- cp internal/buildscripts/packaging/installer/install.ps1 dist/install.ps1
artifacts:
paths:
- dist/install.ps1
- dist/signed/install.ps1
verify-signed-packages:
extends: .trigger-filter
stage: sign-packages
needs:
- build-deb
- build-rpm
- build-msi
- build-tar
- instrumentation-deb
- instrumentation-rpm
- sign-debs
- sign-rpms
- sign-msi
- sign-tar
- agent-bundle-linux
- agent-bundle-windows
- sign-agent-bundles
- sign-ps-installer
script:
- |
set -ex
for pkg in dist/*.rpm dist/*.deb dist/*.msi dist/*.tar.gz dist/*.zip dist/install.ps1; do
if [[ ! -f dist/signed/$(basename $pkg) ]]; then
echo "$pkg was not signed!" >&2
exit 1
fi
if [[ "${pkg##*.}" =~ gz|zip ]] && [[ ! -f dist/signed/$(basename $pkg).asc ]]; then
echo "$pkg was not signed!" >&2
exit 1
fi
done
build-push-linux-image:
extends: .trigger-filter
stage: release
dependencies:
- compile
- agent-bundle-linux
retry: 2
id_tokens: # http://go/gitlab-17
CI_JOB_JWT:
aud: $CICD_VAULT_ADDR
script:
- *docker-reader-role
- docker login -u $CIRCLECI_QUAY_USERNAME -p $CIRCLECI_QUAY_PASSWORD quay.io
- |
# Set env vars
set -e
if [[ -n "${CI_COMMIT_TAG:-}" ]]; then
IMAGE_NAME="quay.io/signalfx/splunk-otel-collector"
IMAGE_TAG=${CI_COMMIT_TAG#v}
else
IMAGE_NAME="quay.io/signalfx/splunk-otel-collector-dev"
IMAGE_TAG=${CI_COMMIT_SHA}
fi
LATEST_TAG=""
if [[ "${CI_COMMIT_BRANCH:-}" = "main" ]] || [[ "${CI_COMMIT_TAG:-}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# Only push latest tag for main and stable releases
LATEST_TAG="latest"
fi
- echo "Building and pushing ${IMAGE_NAME}:${IMAGE_TAG}"
- make docker-otelcol ARCH=amd64,arm64,ppc64le DOCKER_REPO=${DOCKER_HUB_REPO} IMAGE_NAME=${IMAGE_NAME} IMAGE_TAG=${IMAGE_TAG} SKIP_COMPILE=true SKIP_BUNDLE=true PUSH=true
- |
# DEPRECATED: Push manifests for each arch
set -eo pipefail
json=$( docker buildx imagetools inspect --raw ${IMAGE_NAME}:${IMAGE_TAG} )
for arch in "amd64" "arm64" "ppc64le"; do
arch_tag="${IMAGE_TAG}-${arch}"
echo "Creating and pushing ${IMAGE_NAME}:${arch_tag} manifest"
echo "$json" | jq -r ".manifests[] | select(.platform.architecture == \"${arch}\" and .platform.os == \"linux\")" | tee ${arch}.json
docker buildx imagetools create --tag ${IMAGE_NAME}:${arch_tag} --file ${arch}.json
if [[ -n "$LATEST_TAG" ]]; then
latest_tag="${LATEST_TAG}-${arch}"
echo "Creating and pushing ${IMAGE_NAME}:${latest_tag} manifest"
docker buildx imagetools create --tag ${IMAGE_NAME}:${latest_tag} ${IMAGE_NAME}:${arch_tag}
fi
echo "${IMAGE_NAME}:${arch_tag}" > tags_to_sign_${arch}
done
artifacts:
paths:
- tags_to_sign_*
sign-linux-image:
extends: .sign-docker
stage: release
parallel:
matrix:
- ARCH: [amd64, arm64, ppc64le]
needs:
- build-push-linux-image
before_script:
- mv tags_to_sign_${ARCH} tags_to_sign
build-push-windows-image:
extends: .trigger-filter
stage: release
parallel:
matrix:
- WIN_VERSION: ["2019", "2022"]
dependencies:
- sign-exe
- agent-bundle-windows
tags:
- splunk-otel-collector-windows${WIN_VERSION}
retry: 2
variables:
ErrorActionPreference: stop
before_script:
- Copy-Item .\dist\signed\otelcol_windows_amd64.exe .\cmd\otelcol\otelcol.exe
- Copy-Item .\dist\agent-bundle_windows_amd64.zip .\cmd\otelcol\agent-bundle_windows_amd64.zip
- &get-base-image |
if ($env:WIN_VERSION -eq "2019") {
$BASE_IMAGE = $env:WIN_2019_BASE_IMAGE
} else {
$BASE_IMAGE = $env:WIN_2022_BASE_IMAGE
}
- |
docker pull $BASE_IMAGE
if ($LASTEXITCODE -ne 0) { exit 1 }
- &delete-all-images-except-base |
# Delete all images except the base image
$base_id = $(docker images -q $BASE_IMAGE)
foreach ($id in $(docker images -a -q | Get-Unique)) {
if ($id -ne $base_id) {
docker rmi -f $id
}
}
- docker system prune --force
script:
- |
docker login -u $env:CIRCLECI_QUAY_USERNAME -p $env:CIRCLECI_QUAY_PASSWORD quay.io
if ($LASTEXITCODE -ne 0) { exit 1 }
- |
# Set env vars
if ($env:CI_COMMIT_TAG) {
$IMAGE_NAME = "quay.io/signalfx/splunk-otel-collector"
$OLD_IMAGE_NAME = "quay.io/signalfx/splunk-otel-collector-windows"
$tagNumber = $env:CI_COMMIT_TAG.TrimStart("v")
$IMAGE_TAG = "${tagNumber}-${env:WIN_VERSION}"
} else {
$IMAGE_NAME = "quay.io/signalfx/splunk-otel-collector-dev"
$OLD_IMAGE_NAME = "quay.io/signalfx/splunk-otel-collector-windows-dev"
$IMAGE_TAG = "${env:CI_COMMIT_SHA}-${env:WIN_VERSION}"
}
$LATEST_TAG = ""
if ($env:CI_COMMIT_BRANCH -eq "main" -or $env:CI_COMMIT_TAG -match '^v\d+\.\d+\.\d+$') {
# Only push latest tag for main and stable releases
$LATEST_TAG = "latest-${env:WIN_VERSION}"
}
- $JMX_METRIC_GATHERER_RELEASE = $(Get-Content internal\buildscripts\packaging\jmx-metric-gatherer-release.txt)
- |
echo "Building ${IMAGE_NAME}:${IMAGE_TAG}"
docker build -t ${IMAGE_NAME}:${IMAGE_TAG} --build-arg BASE_IMAGE=${BASE_IMAGE} --build-arg JMX_METRIC_GATHERER_RELEASE=${JMX_METRIC_GATHERER_RELEASE} -f .\cmd\otelcol\Dockerfile.windows .\cmd\otelcol\
if ($LASTEXITCODE -ne 0) { exit 1 }
- |
echo "Pushing ${IMAGE_NAME}:${IMAGE_TAG}"
docker push ${IMAGE_NAME}:${IMAGE_TAG}
if ($LASTEXITCODE -ne 0) { exit 1 }
- |
# DEPRECATED: Push image to the windows repo
echo "Tagging and pushing ${OLD_IMAGE_NAME}:${IMAGE_TAG}"
docker tag ${IMAGE_NAME}:${IMAGE_TAG} ${OLD_IMAGE_NAME}:${IMAGE_TAG}
if ($LASTEXITCODE -ne 0) { exit 1 }
docker push ${OLD_IMAGE_NAME}:${IMAGE_TAG}
if ($LASTEXITCODE -ne 0) { exit 1 }
- |
echo "Getting os.version from ${BASE_IMAGE}"
$os_version = (docker manifest inspect $BASE_IMAGE | ConvertFrom-Json).manifests[0].platform."os.version"
if ($LASTEXITCODE -ne 0) { exit 1 }
echo "$os_version"
- |
echo "Creating and pushing ${IMAGE_NAME}:${IMAGE_TAG} manifest"
docker manifest rm ${IMAGE_NAME}:${IMAGE_TAG}
docker manifest create ${IMAGE_NAME}:${IMAGE_TAG} ${IMAGE_NAME}:${IMAGE_TAG}
if ($LASTEXITCODE -ne 0) { exit 1 }
docker manifest annotate --os "windows" --arch "amd64" --os-version ${os_version} ${IMAGE_NAME}:${IMAGE_TAG} ${IMAGE_NAME}:${IMAGE_TAG}
if ($LASTEXITCODE -ne 0) { exit 1 }
docker manifest push ${IMAGE_NAME}:${IMAGE_TAG} --purge
if ($LASTEXITCODE -ne 0) { exit 1 }
- |
# DEPRECATED: Push manifest to the windows repo
echo "Creating and pushing ${OLD_IMAGE_NAME}:${IMAGE_TAG} manifest"
docker manifest rm ${OLD_IMAGE_NAME}:${IMAGE_TAG}
docker manifest create ${OLD_IMAGE_NAME}:${IMAGE_TAG} ${OLD_IMAGE_NAME}:${IMAGE_TAG}
if ($LASTEXITCODE -ne 0) { exit 1 }
docker manifest annotate --os "windows" --arch "amd64" --os-version ${os_version} ${OLD_IMAGE_NAME}:${IMAGE_TAG} ${OLD_IMAGE_NAME}:${IMAGE_TAG}
if ($LASTEXITCODE -ne 0) { exit 1 }
docker manifest push ${OLD_IMAGE_NAME}:${IMAGE_TAG} --purge
if ($LASTEXITCODE -ne 0) { exit 1 }
- |
if ($LATEST_TAG) {
echo "Tagging and pushing ${IMAGE_NAME}:${LATEST_TAG}"
docker tag ${IMAGE_NAME}:${IMAGE_TAG} ${IMAGE_NAME}:${LATEST_TAG}
if ($LASTEXITCODE -ne 0) { exit 1 }
docker push ${IMAGE_NAME}:${LATEST_TAG}
if ($LASTEXITCODE -ne 0) { exit 1 }
echo "Creating and pushing ${IMAGE_NAME}:${LATEST_TAG} manifest"
docker manifest rm ${IMAGE_NAME}:${LATEST_TAG}
docker manifest create ${IMAGE_NAME}:${LATEST_TAG} ${IMAGE_NAME}:${LATEST_TAG}
if ($LASTEXITCODE -ne 0) { exit 1 }
docker manifest annotate --os "windows" --arch "amd64" --os-version ${os_version} ${IMAGE_NAME}:${LATEST_TAG} ${IMAGE_NAME}:${LATEST_TAG}
if ($LASTEXITCODE -ne 0) { exit 1 }
docker manifest push ${IMAGE_NAME}:${LATEST_TAG} --purge
if ($LASTEXITCODE -ne 0) { exit 1 }
}
- |
# DEPRECATED: Push latest tag to the windows repo
if ($LATEST_TAG) {
echo "Tagging and pushing ${OLD_IMAGE_NAME}:${LATEST_TAG}"
docker tag ${OLD_IMAGE_NAME}:${IMAGE_TAG} ${OLD_IMAGE_NAME}:${LATEST_TAG}
if ($LASTEXITCODE -ne 0) { exit 1 }
docker push ${OLD_IMAGE_NAME}:${LATEST_TAG}
if ($LASTEXITCODE -ne 0) { exit 1 }
echo "Creating and pushing ${OLD_IMAGE_NAME}:${LATEST_TAG} manifest"
docker manifest rm ${OLD_IMAGE_NAME}:${LATEST_TAG}
docker manifest create ${OLD_IMAGE_NAME}:${LATEST_TAG} ${OLD_IMAGE_NAME}:${LATEST_TAG}
if ($LASTEXITCODE -ne 0) { exit 1 }
docker manifest annotate --os "windows" --arch "amd64" --os-version ${os_version} ${OLD_IMAGE_NAME}:${LATEST_TAG} ${OLD_IMAGE_NAME}:${LATEST_TAG}
if ($LASTEXITCODE -ne 0) { exit 1 }
docker manifest push ${OLD_IMAGE_NAME}:${LATEST_TAG} --purge
if ($LASTEXITCODE -ne 0) { exit 1 }
}
- echo "${IMAGE_NAME}:${IMAGE_TAG}" > tags
- echo "${OLD_IMAGE_NAME}:${IMAGE_TAG}" >> tags
- (Get-Content -Raw -Path tags) -replace "`r`n", "`n"| Set-Content -NoNewline tags_to_sign_${env:WIN_VERSION}
after_script:
- *get-base-image
- *delete-all-images-except-base
- docker system prune --force
- |
if (Test-Path -Path C:\Users\Administrator\Desktop\ops-scripts\docker-leak-check.exe) {
C:\Users\Administrator\Desktop\ops-scripts\docker-leak-check.exe -remove
}
artifacts:
paths:
- tags_to_sign_${WIN_VERSION}
sign-windows-image:
extends: .sign-docker
stage: release
parallel:
matrix:
- WIN_VERSION: ["2019", "2022"]
needs:
- build-push-windows-image
before_script:
- mv tags_to_sign_${WIN_VERSION} tags_to_sign
release-debs:
extends:
- .trigger-filter
- .submit-signing-request
stage: release
resource_group: artifactory-deb
dependencies:
- sign-debs
retry: 2
before_script:
- *get-artifactory-stage
- pip3 install -r internal/buildscripts/packaging/release/requirements.txt
- apt update && apt install -y curl