forked from DataDog/dd-trace-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
277 lines (256 loc) · 8.29 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
include:
- remote: https://gitlab-templates.ddbuild.io/libdatadog/include/ci_authenticated_job.yml
- remote: https://gitlab-templates.ddbuild.io/apm/packaging.yml
- local: ".gitlab/benchmarks.yml"
- local: ".gitlab/exploration-tests.yml"
- local: ".gitlab/ci-visibility-tests.yml"
stages:
- build
- package
- deploy
- benchmarks
- exploration-tests
- ci-visibility-tests
- generate-signing-key
variables:
REGISTRY: 486234852809.dkr.ecr.us-east-1.amazonaws.com
SONATYPE_USERNAME: robot-sonatype-apm-java
DOWNSTREAM_BRANCH:
value: "master"
description: "Run a specific datadog-reliability-env branch downstream"
FORCE_TRIGGER:
value: "false"
description: "Set to true to override rules in the reliability-env pipeline (e.g. override 'only deploy master')"
.common: &common
tags: [ "runner:main", "size:large" ]
.docker: &docker
tags: [ "runner:docker", "size:large" ]
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/docker:20.10.13
cache:
key: no-cache
policy: pull
cache: &default_cache
key: '$CI_SERVER_VERSION' # Reset the cache every time gitlab is upgraded. ~Every couple months
paths:
- .gradle/wrapper
- .gradle/caches
policy: pull
.gradle_build: &gradle_build
<<: *common
image: ghcr.io/datadog/dd-trace-java-docker-build:v23.10-base
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
build: &build
<<: *gradle_build
stage: build
rules:
- if: '$POPULATE_CACHE'
when: never
- when: on_success
script:
- GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx1900M -Xms512M' -Ddatadog.forkedMaxHeapSize=512M -Ddatadog.forkedMinHeapSize=128M" ./gradlew clean :dd-java-agent:shadowJar --build-cache --parallel --stacktrace --no-daemon --max-workers=8
- echo UPSTREAM_TRACER_VERSION=$(java -jar workspace/dd-java-agent/build/libs/*.jar) >> upstream.env
- echo "BUILD_JOB_NAME=$CI_JOB_NAME" >> build.env
artifacts:
paths:
- 'workspace/dd-java-agent/build/libs/*.jar'
- 'upstream.env'
reports:
dotenv: build.env
build_with_cache:
<<: *build
rules:
- if: '$POPULATE_CACHE'
when: on_success
- when: manual
allow_failure: true
cache:
<<: *default_cache
policy: push
package:
extends: .package
when: on_success # this can't use 'needs: [build]', since build is not available in the scheduled pipeline
script:
- ../.gitlab/build_java_package.sh
package-arm:
extends: .package-arm
when: on_success # this can't use 'needs: [build]', since build is not available in the scheduled pipeline
script:
- ../.gitlab/build_java_package.sh
.release-package:
stage: deploy
variables:
PRODUCT_NAME: auto_inject-java
deploy_to_reliability_env:
stage: deploy
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: on_success
- when: manual
allow_failure: true
trigger:
project: DataDog/apm-reliability/datadog-reliability-env
branch: $DOWNSTREAM_BRANCH
variables:
UPSTREAM_PACKAGE_JOB: $BUILD_JOB_NAME
UPSTREAM_PROJECT_ID: $CI_PROJECT_ID
UPSTREAM_PROJECT_NAME: $CI_PROJECT_NAME
UPSTREAM_PIPELINE_ID: $CI_PIPELINE_ID
UPSTREAM_BRANCH: $CI_COMMIT_REF_NAME
UPSTREAM_COMMIT_SHA: $CI_COMMIT_SHA
FORCE_TRIGGER: $FORCE_TRIGGER
deploy_to_profiling_backend:
stage: deploy
rules:
- if: '$POPULATE_CACHE'
when: never
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: on_success
- if: '$CI_COMMIT_TAG =~ /^v.*/'
when: on_success
- when: manual
allow_failure: true
trigger:
project: DataDog/profiling-backend
branch: dogfooding
variables:
UPSTREAM_PACKAGE_JOB: build
UPSTREAM_PROJECT_ID: $CI_PROJECT_ID
UPSTREAM_PROJECT_NAME: $CI_PROJECT_NAME
UPSTREAM_PIPELINE_ID: $CI_PIPELINE_ID
UPSTREAM_BRANCH: $CI_COMMIT_BRANCH
UPSTREAM_TAG: $CI_COMMIT_TAG
FORCE_TRIGGER: $FORCE_TRIGGER
deploy_to_di_backend:automatic:
stage: deploy
rules:
- if: '$POPULATE_CACHE'
when: never
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: on_success
- if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/'
when: on_success
trigger:
project: DataDog/debugger-demos
branch: main
variables:
UPSTREAM_PACKAGE_JOB: build
UPSTREAM_PROJECT_ID: $CI_PROJECT_ID
UPSTREAM_PROJECT_NAME: $CI_PROJECT_NAME
UPSTREAM_PIPELINE_ID: $CI_PIPELINE_ID
UPSTREAM_BRANCH: $CI_COMMIT_BRANCH
UPSTREAM_TAG: $CI_COMMIT_TAG
UPSTREAM_COMMIT_SHORT_SHA: $CI_COMMIT_SHORT_SHA
deploy_to_di_backend:manual:
stage: deploy
rules:
- if: '$POPULATE_CACHE'
when: never
- when: manual
allow_failure: true
trigger:
project: DataDog/debugger-demos
branch: main
variables:
UPSTREAM_PACKAGE_JOB: build
UPSTREAM_PROJECT_ID: $CI_PROJECT_ID
UPSTREAM_PROJECT_NAME: $CI_PROJECT_NAME
UPSTREAM_PIPELINE_ID: $CI_PIPELINE_ID
UPSTREAM_BRANCH: $CI_COMMIT_BRANCH
UPSTREAM_TAG: $CI_COMMIT_TAG
UPSTREAM_COMMIT_AUTHOR: $CI_COMMIT_AUTHOR
UPSTREAM_COMMIT_SHORT_SHA: $CI_COMMIT_SHORT_SHA
deploy_to_sonatype:
<<: *gradle_build
stage: deploy
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: on_success
- if: '$CI_COMMIT_TAG =~ /^v.*/'
when: on_success
- when: manual
allow_failure: true
script:
- export SONATYPE_PASSWORD=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.sonatype_password --with-decryption --query "Parameter.Value" --out text)
- export GPG_PRIVATE_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.signing.gpg_private_key --with-decryption --query "Parameter.Value" --out text)
- export GPG_PASSWORD=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.signing.gpg_passphrase --with-decryption --query "Parameter.Value" --out text)
- ./gradlew -PbuildInfo.build.number=$CI_JOB_ID publishToSonatype closeSonatypeStagingRepository --max-workers=1 --build-cache --stacktrace --no-daemon
deploy_to_docker_registries:
stage: deploy
rules:
- if: '$POPULATE_CACHE'
when: never
- if: '$CI_COMMIT_TAG =~ /^v.*/'
when: on_success
- when: manual
allow_failure: true
trigger:
project: DataDog/public-images
branch: main
strategy: depend
variables:
IMG_SOURCES: ghcr.io/datadog/dd-trace-java/dd-lib-java-init:$CI_COMMIT_SHA
IMG_DESTINATIONS: dd-lib-java-init:$CI_COMMIT_TAG
IMG_SIGNING: "false"
deploy_latest_tag_to_docker_registries:
stage: deploy
rules:
- if: '$POPULATE_CACHE'
when: never
- if: '$CI_COMMIT_TAG =~ /^v1\..*/'
when: on_success
- when: manual
allow_failure: true
trigger:
project: DataDog/public-images
branch: main
strategy: depend
variables:
IMG_SOURCES: ghcr.io/datadog/dd-trace-java/dd-lib-java-init:$CI_COMMIT_SHA
IMG_DESTINATIONS: dd-lib-java-init:latest
IMG_SIGNING: "false"
create_key:
stage: generate-signing-key
when: manual
needs: []
tags: [ "runner:docker", "size:large" ]
variables:
PROJECT_NAME: "dd-trace-java"
EXPORT_TO_KEYSERVER: "true"
image: $REGISTRY/ci/agent-key-management-tools/gpg:1
script:
- /create.sh
artifacts:
expire_in: 13 mos
paths:
- pubkeys
tracer-base-image-release:
extends: .ci_authenticated_job
stage: deploy
rules:
- if: '$POPULATE_CACHE'
when: never
- if: '$CI_COMMIT_TAG =~ /^v1\..*/'
when: on_success
dependencies:
- build
script:
- echo $GH_TOKEN|docker login ghcr.io/datadog -u uploader --password-stdin
- mkdir -p ./tooling/ci/binaries/ && cp workspace/dd-java-agent/build/libs/*.jar ./tooling/ci/binaries/dd-java-agent.jar
- docker build -t ghcr.io/datadog/dd-trace-java/dd-trace-java:latest -f ./tooling/ci/Dockerfile .
- docker push ghcr.io/datadog/dd-trace-java/dd-trace-java:latest
tracer-base-image-snapshot:
extends: .ci_authenticated_job
stage: deploy
rules:
- if: '$POPULATE_CACHE'
when: never
- if: '$CI_COMMIT_BRANCH == "master"'
when: on_success
dependencies:
- build
script:
- echo $GH_TOKEN|docker login ghcr.io/datadog -u uploader --password-stdin
- mkdir -p ./tooling/ci/binaries/ && cp workspace/dd-java-agent/build/libs/*.jar ./tooling/ci/binaries/dd-java-agent.jar
- docker build -t ghcr.io/datadog/dd-trace-java/dd-trace-java:latest_snapshot -f ./tooling/ci/Dockerfile .
- docker push ghcr.io/datadog/dd-trace-java/dd-trace-java:latest_snapshot