forked from signalfx/splunk-otel-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
817 lines (773 loc) · 23.2 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
default:
image: '${DOCKER_CICD_REPO}/ci-container:debian-buster'
stages:
- sast-oss-scan
- build
- sign-binaries
- package
- cve-scan
- sign-packages
- release
- sign-metadata
- 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'
- project: 'core-ee/signing/api-integration'
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
fossa:
extends: .oss-scan
stage: sast-oss-scan
only:
- main
- schedules
# allow_failure: false
.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
.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'
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
key:
files:
- internal/buildscripts/packaging/release/requirements.txt
paths:
- .cache/pip
retry: 2
before_script:
- *get-artifactory-stage
script:
- pip3 install -r internal/buildscripts/packaging/release/requirements.txt
- |
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
.go-cache:
image: '${DOCKER_HUB_REPO}/golang:1.19.0'
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
.docker-reader-role: &docker-reader-role |
creds-helper init
eval $(creds-helper docker --eval "artifactory:v2/cloud/role/docker-reader-role")
compile:
extends:
- .trigger-filter
- .go-cache
stage: build
parallel:
matrix:
- TARGET: [binaries-darwin_amd64, binaries-linux_amd64, binaries-linux_arm64, binaries-windows_amd64, binaries-linux_ppc64le]
script: make $TARGET
after_script:
- if [ -e bin/otelcol ]; then rm -f bin/otelcol; fi # remove the symlink
- if [ -e bin/translatesfx ]; then rm -f bin/translatesfx; fi # remove the symlink
- if [ -e bin/migratecheckpoint ]; then rm -f bin/migratecheckpoint; fi # remove the symlink
artifacts:
paths:
- bin/otelcol_*
- bin/translatesfx_*
- bin/migratecheckpoint_*
libsplunk:
extends: .trigger-filter
stage: build
retry: 2
parallel:
matrix:
- ARCH: ["amd64", "arm64"]
script:
- make -C instrumentation dist ARCH=${ARCH}
artifacts:
paths:
- instrumentation/dist/libsplunk_*.so
.instrumentation-deb-rpm:
extends: .trigger-filter
stage: package
needs:
- libsplunk
parallel:
matrix:
- ARCH: [amd64, arm64]
before_script:
- ./instrumentation/packaging/fpm/install-deps.sh
script:
- ./instrumentation/packaging/fpm/${PKG_TYPE}/build.sh "${CI_COMMIT_TAG:-}" "$ARCH" "./dist"
instrumentation-deb:
extends: .instrumentation-deb-rpm
variables:
PKG_TYPE: deb
artifacts:
paths:
- dist/*.deb
instrumentation-rpm:
extends: .instrumentation-deb-rpm
variables:
PKG_TYPE: rpm
artifacts:
paths:
- dist/*.rpm
sign-exe:
extends:
- .trigger-filter
- .submit-request
stage: sign-binaries
needs:
- compile
parallel:
matrix:
- TARGET: [otelcol, translatesfx]
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-request
stage: sign-binaries
needs:
- compile
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_amd64 translatesfx_darwin_amd64 && 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_amd64
- dist/signed/translatesfx_darwin_amd64
build-linux-image:
extends: .trigger-filter
stage: package
needs:
- compile
parallel:
matrix:
- ARCH: [amd64, arm64, ppc64le]
retry: 2
script:
- *docker-reader-role
- make docker-otelcol ARCH=${ARCH} DOCKER_REPO=${DOCKER_HUB_REPO} SKIP_COMPILE=true
- arch=$( docker inspect --format='{{.Architecture}}' otelcol:${ARCH} )
- if [[ "$arch" != "$ARCH" ]]; then exit 1; fi
after_script:
- mkdir -p dist
- docker save -o dist/otelcol-${ARCH}.tar otelcol:${ARCH}
artifacts:
paths:
- dist/otelcol-*.tar
.build-tar-deb-rpm:
stage: package
needs:
- compile
parallel:
matrix:
- ARCH: [amd64, arm64]
before_script:
- ./internal/buildscripts/packaging/fpm/install-deps.sh
script:
- ./internal/buildscripts/packaging/fpm/${PKG_TYPE}/build.sh "${CI_COMMIT_TAG:-}" "$ARCH" "./dist"
build-deb:
extends:
- .trigger-filter
- .build-tar-deb-rpm
variables:
PKG_TYPE: deb
artifacts:
paths:
- dist/*.deb
build-rpm:
extends:
- .trigger-filter
- .build-tar-deb-rpm
variables:
PKG_TYPE: rpm
artifacts:
paths:
- dist/*.rpm
build-tar:
extends:
- .trigger-filter
- .build-tar-deb-rpm
variables:
PKG_TYPE: tar
artifacts:
paths:
- dist/*.tar.gz
build-msi:
extends: .trigger-filter
stage: package
needs:
- sign-exe
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
- cp -f dist/signed/translatesfx_windows_amd64.exe bin/translatesfx_windows_amd64.exe
script:
- make msi SKIP_COMPILE=true VERSION=${CI_COMMIT_TAG:-}
artifacts:
paths:
- dist/*.msi
sign-debs:
extends:
- .trigger-filter
- .submit-request
stage: sign-packages
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-request
stage: sign-packages
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-request
stage: sign-packages
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 *.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-request
stage: sign-packages
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
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
script:
- |
set -ex
for pkg in dist/*.rpm dist/*.deb dist/*.msi dist/*.tar.gz; do
if [[ ! -f dist/signed/$(basename $pkg) ]]; then
echo "$pkg was not signed!" >&2
exit 1
fi
if [[ "${pkg##*.}" = "gz" && ! -f dist/signed/$(basename $pkg).asc ]]; then
echo "$pkg was not signed!" >&2
exit 1
fi
done
push-linux-image:
extends: .trigger-filter
stage: release
dependencies:
- build-linux-image
retry: 2
before_script:
- docker load -i dist/otelcol-amd64.tar
- docker load -i dist/otelcol-arm64.tar
- docker load -i dist/otelcol-ppc64le.tar
script:
- 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"
MANIFEST_TAG=${CI_COMMIT_TAG#v}
else
IMAGE_NAME="quay.io/signalfx/splunk-otel-collector-dev"
MANIFEST_TAG=$CI_COMMIT_SHA
fi
- |
# Tag and push images
set -e
for arch in "amd64" "arm64" "ppc64le"; do
ARCH_TAG="${MANIFEST_TAG}-${arch}"
echo "Tagging and pushing ${IMAGE_NAME}:${ARCH_TAG}"
docker tag otelcol:${arch} ${IMAGE_NAME}:${ARCH_TAG}
docker push ${IMAGE_NAME}:${ARCH_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-${arch}"
echo "Tagging and pushing ${IMAGE_NAME}:${LATEST_TAG}"
docker tag ${IMAGE_NAME}:${ARCH_TAG} ${IMAGE_NAME}:${LATEST_TAG}
docker push ${IMAGE_NAME}:${LATEST_TAG}
fi
done
- |
# Create and push image manifests
set -e
echo "Creating and pushing ${IMAGE_NAME}:${MANIFEST_TAG} manifest"
docker manifest create ${IMAGE_NAME}:${MANIFEST_TAG} --amend ${IMAGE_NAME}:${MANIFEST_TAG}-amd64 --amend ${IMAGE_NAME}:${MANIFEST_TAG}-arm64 --amend ${IMAGE_NAME}:${MANIFEST_TAG}-ppc64le
docker manifest push ${IMAGE_NAME}:${MANIFEST_TAG}
if [[ "${CI_COMMIT_BRANCH:-}" = "main" ]] || [[ "${CI_COMMIT_TAG:-}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# only push latest manifest tag for main and stable releases
echo "Creating and pushing ${IMAGE_NAME}:latest manifest"
docker manifest create ${IMAGE_NAME}:latest --amend ${IMAGE_NAME}:latest-amd64 --amend ${IMAGE_NAME}:latest-arm64 --amend ${IMAGE_NAME}:latest-ppc64le
docker manifest push ${IMAGE_NAME}:latest
fi
- docker pull ${IMAGE_NAME}:${MANIFEST_TAG}
- docker inspect --format='{{.RepoDigests}}' ${IMAGE_NAME}:${MANIFEST_TAG}-amd64 | tee dist/linux_amd64_digest.txt
- docker inspect --format='{{.RepoDigests}}' ${IMAGE_NAME}:${MANIFEST_TAG}-arm64 | tee dist/linux_arm64_digest.txt
- docker inspect --format='{{.RepoDigests}}' ${IMAGE_NAME}:${MANIFEST_TAG}-ppc64le | tee dist/linux_ppc64le_digest.txt
- docker manifest inspect ${IMAGE_NAME}:${MANIFEST_TAG} | tee dist/manifest_digest.txt
artifacts:
paths:
- dist/linux_amd64_digest.txt
- dist/linux_arm64_digest.txt
- dist/linux_ppc64le_digest.txt
- dist/manifest_digest.txt
build-push-windows-image:
extends: .trigger-filter
stage: release
dependencies:
- sign-exe
tags:
- windows
retry: 2
before_script:
- Copy-Item .\dist\signed\otelcol_windows_amd64.exe .\cmd\otelcol\otelcol.exe
- Copy-Item .\dist\signed\translatesfx_windows_amd64.exe .\cmd\otelcol\translatesfx.exe
script:
- docker login -u $env:CIRCLECI_QUAY_USERNAME -p $env:CIRCLECI_QUAY_PASSWORD quay.io
- |
$ErrorActionPreference = 'Stop'
if ($env:CI_COMMIT_TAG) {
$IMAGE_NAME = "quay.io/signalfx/splunk-otel-collector-windows"
$IMAGE_TAG = $env:CI_COMMIT_TAG.TrimStart("v")
} else {
$IMAGE_NAME = "quay.io/signalfx/splunk-otel-collector-windows-dev"
$IMAGE_TAG = $env:CI_COMMIT_SHA
}
$SMART_AGENT_RELEASE = $((Get-Content internal\buildscripts\packaging\smart-agent-release.txt).TrimStart("v"))
echo "Building ${IMAGE_NAME}:${IMAGE_TAG}"
docker build -t ${IMAGE_NAME}:${IMAGE_TAG} --build-arg BASE_IMAGE=mcr.microsoft.com/windows/servercore:1809 --build-arg SMART_AGENT_RELEASE=${SMART_AGENT_RELEASE} -f .\cmd\otelcol\Dockerfile.windows .\cmd\otelcol\
echo "Pushing ${IMAGE_NAME}:${IMAGE_TAG}"
docker push ${IMAGE_NAME}:${IMAGE_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
echo "Tagging and pushing ${IMAGE_NAME}:latest"
docker tag ${IMAGE_NAME}:${IMAGE_TAG} ${IMAGE_NAME}:latest
docker push ${IMAGE_NAME}:latest
}
- docker inspect --format='{{.RepoDigests}}' ${IMAGE_NAME}:${IMAGE_TAG} | Tee-Object -FilePath dist/windows_digest.txt
after_script:
- docker image prune --all --force
artifacts:
paths:
- dist/windows_digest.txt
build-push-windows2022-image:
extends: .trigger-filter
stage: release
dependencies:
- sign-exe
tags:
- windows2022
retry: 2
before_script:
- Copy-Item .\dist\signed\otelcol_windows_amd64.exe .\cmd\otelcol\otelcol.exe
- Copy-Item .\dist\signed\translatesfx_windows_amd64.exe .\cmd\otelcol\translatesfx.exe
script:
- docker login -u $env:CIRCLECI_QUAY_USERNAME -p $env:CIRCLECI_QUAY_PASSWORD quay.io
- |
$ErrorActionPreference = 'Stop'
if ($env:CI_COMMIT_TAG) {
$IMAGE_NAME = "quay.io/signalfx/splunk-otel-collector-windows"
$tagNumber = $env:CI_COMMIT_TAG.TrimStart("v")
$IMAGE_TAG = "${tagNumber}-2022"
} else {
$IMAGE_NAME = "quay.io/signalfx/splunk-otel-collector-windows-dev"
$IMAGE_TAG = "${env:CI_COMMIT_SHA}-2022"
}
$SMART_AGENT_RELEASE = $((Get-Content internal\buildscripts\packaging\smart-agent-release.txt).TrimStart("v"))
echo "Building ${IMAGE_NAME}:${IMAGE_TAG}"
docker build -t ${IMAGE_NAME}:${IMAGE_TAG} --build-arg BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022 --build-arg SMART_AGENT_RELEASE=${SMART_AGENT_RELEASE} -f .\cmd\otelcol\Dockerfile.windows .\cmd\otelcol\
echo "Pushing ${IMAGE_NAME}:${IMAGE_TAG}"
docker push ${IMAGE_NAME}:${IMAGE_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
echo "Tagging and pushing ${IMAGE_NAME}:latest-2022"
docker tag ${IMAGE_NAME}:${IMAGE_TAG} ${IMAGE_NAME}:latest-2022
docker push ${IMAGE_NAME}:latest-2022
}
- docker inspect --format='{{.RepoDigests}}' ${IMAGE_NAME}:${IMAGE_TAG} | Tee-Object -FilePath dist/windows_2022_digest.txt
after_script:
- docker image prune --all --force
artifacts:
paths:
- dist/windows_2022_digest.txt
release-debs:
extends:
- .trigger-filter
- .deploy-release
stage: release
resource_group: artifactory-deb
dependencies:
- sign-debs
variables:
PATHS: dist/signed/*.deb
artifacts:
paths:
- dist/signed/*.deb
- Release
release-rpms:
extends:
- .trigger-filter
- .deploy-release
stage: release
parallel:
matrix:
- ARCH: ['x86_64', 'aarch64']
resource_group: artifactory-rpm
dependencies:
- sign-rpms
variables:
PATHS: dist/signed/*${ARCH}.rpm
after_script:
- mkdir ${ARCH}
- mv repomd.xml ${ARCH}/repomd.xml
artifacts:
paths:
- dist/signed/*${ARCH}.rpm
- ${ARCH}/repomd.xml
choco-release:
extends: .trigger-filter
stage: release
dependencies:
- sign-msi
tags:
- windows
script:
- |
$ErrorActionPreference = 'Stop'
Set-PSDebug -Trace 1
$msi_file_name = Resolve-Path .\dist\signed\splunk-otel-collector*.msi | Split-Path -leaf
if ($msi_file_name -match '(\d+\.\d+\.\d+)(\.\d+)?') {
$version = $matches[0]
} else {
throw "Failed to get version from $msi_file_name"
}
.\internal\buildscripts\packaging\choco\make.ps1 build_choco -Version $version -BuildDir .\dist\signed
- Test-Path .\dist\signed\splunk-otel-collector.${version}.nupkg
- |
# Only push the choco package for stable release tags
if ($env:CI_COMMIT_TAG -match '^v\d+\.\d+\.\d+$') {
choco push -k $env:CHOCO_TOKEN .\dist\signed\splunk-otel-collector.${version}.nupkg
}
artifacts:
paths:
- dist/signed/*.nupkg
sign-apt-metadata:
extends:
- .trigger-filter
- .submit-request
stage: sign-metadata
resource_group: artifactory-deb
needs:
- release-debs
variables:
ARTIFACT: Release
SIGN_TYPE: GPG
after_script:
- mv Release signed/Release
artifacts:
paths:
- signed/Release
- signed/Release.asc
sign-yum-metadata:
extends:
- .trigger-filter
- .submit-request
stage: sign-metadata
parallel:
matrix:
- ARCH: ['x86_64', 'aarch64']
resource_group: artifactory-rpm
needs:
- release-rpms
variables:
ARTIFACT: ${ARCH}/repomd.xml
SIGN_TYPE: GPG
DOWNLOAD_DIR: signed/${ARCH}
after_script:
- mv ${ARCH}/repomd.xml signed/${ARCH}/repomd.xml
artifacts:
paths:
- signed/${ARCH}/repomd.xml
- signed/${ARCH}/repomd.xml.asc
upload-apt-signature:
extends: .trigger-filter
stage: sign-metadata
resource_group: artifactory-deb
needs:
- sign-apt-metadata
before_script:
- *get-artifactory-stage
script:
- curl -u ${ARTIFACTORY_USERNAME}:${ARTIFACTORY_TOKEN} -X PUT "https://splunk.jfrog.io/artifactory/otel-collector-deb/dists/${STAGE}/Release.gpg" -T signed/Release.asc
upload-yum-signature:
extends: .trigger-filter
stage: sign-metadata
resource_group: artifactory-rpm
parallel:
matrix:
- ARCH: ['x86_64', 'aarch64']
needs:
- sign-yum-metadata
before_script:
- *get-artifactory-stage
script:
- curl -u ${ARTIFACTORY_USERNAME}:${ARTIFACTORY_TOKEN} -X PUT "https://splunk.jfrog.io/artifactory/otel-collector-rpm/${STAGE}/${ARCH}/repodata/repomd.xml.asc" -T signed/${ARCH}/repomd.xml.asc
github-release:
extends:
- .trigger-filter
- .go-cache
stage: github-release
dependencies:
- compile
- libsplunk
- sign-exe
- sign-osx
- release-debs
- release-rpms
- sign-msi
- sign-tar
- push-linux-image
- build-push-windows-image
- build-push-windows2022-image
- choco-release
script:
- mkdir -p dist/assets
- cp bin/otelcol_linux_* dist/assets/
- cp bin/translatesfx_linux_* dist/assets/
- cp instrumentation/dist/libsplunk_*.so dist/assets/
- cp dist/signed/* dist/assets/
- pushd dist/assets && shasum -a 256 * > checksums.txt && popd
- |
# only create github release for stable release tags
set -e
if [[ "${CI_COMMIT_TAG:-}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
release_notes="$( ./internal/buildscripts/packaging/release/gh-release-notes.sh "$CI_COMMIT_TAG" )"
ghr -t "$GITHUB_TOKEN" -u signalfx -r splunk-otel-collector -n "$CI_COMMIT_TAG" -b "$release_notes" --replace "$CI_COMMIT_TAG" dist/assets/
fi
artifacts:
when: always
paths:
- dist/assets
.ansible:
image: 'cimg/python:3.9'
only:
- /^ansible-v[0-9]+\.[0-9]+\.[0-9]+.*/
except:
- branches
- schedules
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
key: "ansible-pip-cache"
paths:
- .cache/pip
ansible-build:
extends: .ansible
stage: build
artifacts:
paths:
- dist/
before_script:
- pip3 install ansible==3.4.0
script:
- ansible-galaxy collection build ./deployments/ansible --output-path ./dist
ansible-release:
extends: .ansible
stage: release
before_script:
- pip3 install ansible==3.4.0 yq==2.12.0
script:
- export COLLECTION_VERSION=$(cat ./deployments/ansible/galaxy.yml | yq .version -r)
- ansible-galaxy collection publish ./dist/signalfx-splunk_otel_collector-${COLLECTION_VERSION}.tar.gz --token=${ANSIBLE_GALAXY_TOKEN}
puppet-release:
image: '${DOCKER_HUB_REPO}/ruby:2.6-buster'
stage: release
only:
variables:
- $CI_COMMIT_TAG =~ /^puppet-v[0-9]+\.[0-9]+\.[0-9]+.*/
except:
- schedules
before_script:
- gem install bundler
- cd deployments/puppet
- bundle install
- bundle exec rake module:clean
script:
- bundle exec rake module:push
artifacts:
paths:
- deployments/puppet/pkg/*.tar.gz
cve-scan:
extends: .go-cache
stage: cve-scan
retry: 2
only:
- main
- schedules
before_script:
- apt-get update
- apt-get install -y ca-certificates curl gnupg lsb-release
- curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
- apt-get update
- apt-get install -y docker-ce-cli docker-scan-plugin
script:
- *docker-reader-role
- |
if [ -f dist/otelcol-amd64.tar ]; then
docker load -i dist/otelcol-amd64.tar
docker tag otelcol:amd64 otelcol:latest
else
make docker-otelcol DOCKER_REPO=${DOCKER_HUB_REPO}
fi
- docker scan --accept-license --login --token ${SNYK_AUTH_TOKEN}
- docker scan --severity high otelcol
after_script:
- |
if [ "$CI_JOB_STATUS" != "success" ]; then
curl -X POST ${SLACK_WEBHOOK_URL} -H 'Content-Type: application/json' \
--data "{\"blocks\": [{\"type\": \"section\",\"text\": {\"type\": \"mrkdwn\",\"text\": \"*@here Gitlab Job #${CI_JOB_ID}*\"}},{\"type\": \"section\",\"text\": {\"type\": \"mrkdwn\",\"text\": \"*:ghost: Vulnerability scan failed on splunk-otel-collector*\"},\"accessory\": {\"type\": \"button\",\"text\": {\"type\": \"plain_text\",\"text\": \"More Info\",\"emoji\": true},\"style\": \"danger\",\"url\": \"${CI_JOB_URL}\",\"action_id\": \"button-action\"}}]}"
fi
chef-release:
image: '${DOCKER_HUB_REPO}/ruby:2.7-buster'
stage: release
only:
variables:
- $CI_COMMIT_TAG =~ /^chef-v[0-9]+\.[0-9]+\.[0-9]+.*/
except:
- schedules
before_script:
- mkdir -p ~/.chef
- cat "$CHEF_PEM" > ~/.chef/signalfx.pem
- cat "$CHEF_KNIFE_RB" > ~/.chef/knife.rb
- gem install knife
- mkdir -p /tmp/cookbooks
- cp -r deployments/chef /tmp/cookbooks/splunk_otel_collector
script:
- knife supermarket share -o /tmp/cookbooks splunk_otel_collector