File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -186,7 +186,32 @@ default:
186186 after_script :
187187 - *cgroup_info
188188
189+ # Checks and fail early if central credentials are incorrect, indeed, when a new token is generated
190+ # on the central publisher protal, it invalidates the old one. This checks prevents going further.
191+ # See https://datadoghq.atlassian.net/wiki/x/Oog5OgE
192+ pre-release-checks :
193+ image : ghcr.io/datadog/dd-trace-java-docker-build:${BUILDER_IMAGE_VERSION_PREFIX}base
194+ stage : .pre
195+ rules :
196+ - if : ' $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
197+ when : on_success
198+ allow_failure : false
199+ script :
200+ - |
201+ SONATYPE_USERNAME=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.central_username --with-decryption --query "Parameter.Value" --out text)
202+ SONATYPE_PASSWORD=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.central_password --with-decryption --query "Parameter.Value" --out text)
203+ # See https://central.sonatype.org/publish/publish-portal-api/
204+ # 15e0cbbb-deff-421e-9e02-296a24d0cada is deployment, any deployment id listed in central work, the idea is to check whether the token can authenticate
205+ curl --request POST --include --fail https://central.sonatype.com/api/v1/publisher/status?id=15e0cbbb-deff-421e-9e02-296a24d0cada --header "Authorization: Bearer $(printf "$SONATYPE_USERNAME:$SONATYPE_PASSWORD" | base64)"
206+ if [ $? -ne 0 ]; then
207+ echo "Failed to authenticate against central. Check credentials, see https://datadoghq.atlassian.net/wiki/x/Oog5OgE"
208+ exit 1
209+ fi
210+
189211build :
212+ needs :
213+ - job : pre-release-checks
214+ optional : true
190215 extends : .gradle_build
191216 variables :
192217 BUILD_CACHE_POLICY : push
You can’t perform that action at this time.
0 commit comments