Skip to content

Commit ef62d3a

Browse files
sarahchen6devflow.devflow-routing-intake
andauthored
Use ossrh-staging-api releases for Maven Central credential check (#10942)
Use ossrh-staging-api releases for Maven Central credential check Temporarily comment out job rules for testing Use bad credentials and except failure Revert testing changes Co-authored-by: devflow.devflow-routing-intake <devflow.devflow-routing-intake@kubernetes.us1.ddbuild.io>
1 parent 8b69db2 commit ef62d3a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

.gitlab-ci.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,24 @@ maven-central-pre-release-check:
222222
image: ${BUILDER_IMAGE_REPO}:${BUILDER_IMAGE_VERSION_PREFIX}base
223223
stage: .pre
224224
rules:
225+
- if: '$CI_COMMIT_BRANCH == "master"'
226+
when: on_success
227+
allow_failure: false
225228
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
226229
when: on_success
227230
allow_failure: false
228231
script:
229232
- |
230233
MAVEN_CENTRAL_USERNAME=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.central_username --with-decryption --query "Parameter.Value" --out text)
231234
MAVEN_CENTRAL_PASSWORD=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.central_password --with-decryption --query "Parameter.Value" --out text)
232-
# See https://central.sonatype.org/publish/publish-portal-api/
233-
# 15e0cbbb-deff-421e-9e02-296a24d0cada is deployment, any deployment id listed in central work, the idea is to check whether the token can authenticate
234-
curl --request POST --include --fail https://central.sonatype.com/api/v1/publisher/status?id=15e0cbbb-deff-421e-9e02-296a24d0cada --header "Authorization: Bearer $(printf "$MAVEN_CENTRAL_USERNAME:$MAVEN_CENTRAL_PASSWORD" | base64)"
235-
if [ $? -ne 0 ]; then
236-
echo "Failed to authenticate against central. Check credentials, see https://datadoghq.atlassian.net/wiki/x/Oog5OgE"
235+
# See https://central.sonatype.org/publish/publish-portal-ossrh-staging-api/
236+
# Use the staging API search endpoint to validate the tokens without relying on a specific deployment
237+
AUTHORIZATION_HEADER="Authorization: Bearer $(printf '%s:%s' "$MAVEN_CENTRAL_USERNAME" "$MAVEN_CENTRAL_PASSWORD" | base64)"
238+
if ! curl --silent --show-error --fail \
239+
"https://ossrh-staging-api.central.sonatype.com/manual/search/repositories?ip=any" \
240+
--header "$AUTHORIZATION_HEADER" \
241+
> /dev/null; then
242+
echo "Failed to authenticate tokens against maven central staging API. Check credentials and see https://datadoghq.atlassian.net/wiki/x/Oog5OgE"
237243
exit 1
238244
fi
239245

0 commit comments

Comments
 (0)