Skip to content

Commit b681823

Browse files
authored
Clean dd-octo-sts workflow and add pre-release check (#9227)
1 parent 3d41cc5 commit b681823

File tree

1 file changed

+34
-38
lines changed

1 file changed

+34
-38
lines changed

.gitlab-ci.yml

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,10 @@ default:
193193
after_script:
194194
- *cgroup_info
195195

196-
# TODO: Add a pre-release check to see if the dd-octo-sts token is working.
197-
# Checks and fail early if central credentials are incorrect, indeed, when a new token is generated
198-
# on the central publisher protal, it invalidates the old one. This checks prevents going further.
196+
# Check and fail early if maven central credentials are incorrect. When a new token is generated
197+
# on the central publisher portal, it invalidates the old one. This check prevents going further.
199198
# See https://datadoghq.atlassian.net/wiki/x/Oog5OgE
200-
pre-release-checks:
199+
maven-central-pre-release-check:
201200
image: ghcr.io/datadog/dd-trace-java-docker-build:${BUILDER_IMAGE_VERSION_PREFIX}base
202201
stage: .pre
203202
rules:
@@ -216,9 +215,37 @@ pre-release-checks:
216215
exit 1
217216
fi
218217
218+
dd-octo-sts-pre-release-check:
219+
image: registry.ddbuild.io/images/dd-octo-sts-ci-base:2025.06-1
220+
stage: .pre
221+
tags: [ "arch:amd64" ]
222+
id_tokens:
223+
DDOCTOSTS_ID_TOKEN:
224+
aud: dd-octo-sts
225+
rules:
226+
- if: '$POPULATE_CACHE'
227+
when: never
228+
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
229+
when: on_success
230+
allow_failure: false
231+
before_script:
232+
- dd-octo-sts version
233+
- dd-octo-sts debug --scope DataDog/dd-trace-java --policy self.gitlab.release
234+
- dd-octo-sts token --scope DataDog/dd-trace-java --policy self.gitlab.release > test-github-token.txt
235+
script:
236+
- gh auth login --with-token < test-github-token.txt
237+
- gh auth status
238+
after_script:
239+
- dd-octo-sts revoke -t $(cat test-github-token.txt)
240+
retry:
241+
max: 2
242+
when: always
243+
219244
build:
220245
needs:
221-
- job: pre-release-checks
246+
- job: maven-central-pre-release-check
247+
optional: true
248+
- job: dd-octo-sts-pre-release-check
222249
optional: true
223250
extends: .gradle_build
224251
variables:
@@ -822,15 +849,14 @@ deploy_artifacts_to_github:
822849
# The deploy_to_maven_central job is not run for release candidate versions
823850
optional: true
824851
before_script:
825-
# Get token
826852
- dd-octo-sts version
827853
- dd-octo-sts debug --scope DataDog/dd-trace-java --policy self.gitlab.release
828854
- dd-octo-sts token --scope DataDog/dd-trace-java --policy self.gitlab.release > github-token.txt
829855
script:
830856
- gh auth login --with-token < github-token.txt
831-
- gh auth status # Maybe helpful to have this output in logs?
857+
- gh auth status
832858
- export VERSION=${CI_COMMIT_TAG##v} # remove "v" from front of tag to get version
833-
- cp workspace/dd-java-agent/build/libs/dd-java-agent-${VERSION}.jar workspace/dd-java-agent/build/libs/dd-java-agent.jar # we upload two filenames
859+
- cp workspace/dd-java-agent/build/libs/dd-java-agent-${VERSION}.jar workspace/dd-java-agent/build/libs/dd-java-agent.jar # upload two filenames
834860
- gh release upload --clobber --repo DataDog/dd-trace-java $CI_COMMIT_TAG workspace/dd-java-agent/build/libs/dd-java-agent.jar
835861
- gh release upload --clobber --repo DataDog/dd-trace-java $CI_COMMIT_TAG workspace/dd-java-agent/build/libs/dd-java-agent-${VERSION}.jar
836862
- gh release upload --clobber --repo DataDog/dd-trace-java $CI_COMMIT_TAG workspace/dd-trace-api/build/libs/dd-trace-api-${VERSION}.jar
@@ -841,36 +867,6 @@ deploy_artifacts_to_github:
841867
max: 2
842868
when: always
843869

844-
# This is the original job that uses the AWS SSM token retrieval method. Allow manual triggering in case the dd-octo-sts token is not working.
845-
# TODO: Remove this job once the dd-octo-sts token is provably working.
846-
deploy_artifacts_to_github_old:
847-
stage: publish
848-
image: registry.ddbuild.io/github-cli:v27480869-eafb11d-2.43.0
849-
rules:
850-
- if: '$POPULATE_CACHE'
851-
when: never
852-
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
853-
when: manual
854-
# Requires the deploy_to_maven_central job to have run first (the UP-TO-DATE gradle check across jobs is broken)
855-
# This will deploy the artifacts built from the publishToSonatype task to the GitHub release
856-
needs:
857-
- job: deploy_to_maven_central
858-
# The deploy_to_maven_central job is not run for release candidate versions
859-
optional: true
860-
script:
861-
- aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.gh_release_token --with-decryption --query "Parameter.Value" --out text > github-token.txt
862-
- gh auth login --with-token < github-token.txt
863-
- gh auth status # Maybe helpful to have this output in logs?
864-
- export VERSION=${CI_COMMIT_TAG##v} # remove "v" from front of tag to get version
865-
- cp workspace/dd-java-agent/build/libs/dd-java-agent-${VERSION}.jar workspace/dd-java-agent/build/libs/dd-java-agent.jar # we upload two filenames
866-
- gh release upload --clobber --repo DataDog/dd-trace-java $CI_COMMIT_TAG workspace/dd-java-agent/build/libs/dd-java-agent.jar
867-
- gh release upload --clobber --repo DataDog/dd-trace-java $CI_COMMIT_TAG workspace/dd-java-agent/build/libs/dd-java-agent-${VERSION}.jar
868-
- gh release upload --clobber --repo DataDog/dd-trace-java $CI_COMMIT_TAG workspace/dd-trace-api/build/libs/dd-trace-api-${VERSION}.jar
869-
- gh release upload --clobber --repo DataDog/dd-trace-java $CI_COMMIT_TAG workspace/dd-trace-ot/build/libs/dd-trace-ot-${VERSION}.jar
870-
retry:
871-
max: 2
872-
when: always
873-
874870
requirements_json_test:
875871
rules:
876872
- when: on_success

0 commit comments

Comments
 (0)