Skip to content

Commit b19ae7d

Browse files
committed
Updated the cred validator to new API
1 parent 5950dbc commit b19ae7d

1 file changed

Lines changed: 85 additions & 22 deletions

File tree

.github/workflows/credential-validation.yml

Lines changed: 85 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Credential Validation
22

33
on:
44
workflow_dispatch: # Triggered by Jenkins or manually
5+
pull_request: # Run on PRs to verify the fix
6+
branches:
7+
- master
58

69
jobs:
710
validate-credentials:
@@ -35,31 +38,91 @@ jobs:
3538
id: validate_maven_central
3639
if: always() # Run even if JFrog validation fails
3740
run: |
38-
echo "Testing Maven Central (OSSRH) connection..."
41+
echo "Testing Maven Central (OSSRH) credentials..."
42+
echo ""
3943
40-
# Test authentication against Nexus staging profiles API
41-
HTTP_CODE=$(curl -s -o /dev/null -w '%{http_code}' \
44+
# Test 1: Check actual Maven repository endpoint (what mvn deploy uses)
45+
echo "Test 1: Checking Maven repository authentication..."
46+
REPO_CODE=$(curl -s -o /dev/null -w '%{http_code}' \
4247
-u "${{ secrets.OSSRH_USERNAME }}:${{ secrets.OSSRH_PASSWORD }}" \
43-
"https://oss.sonatype.org/service/local/staging/profiles")
48+
-X GET \
49+
"https://oss.sonatype.org/service/local/repositories")
4450
45-
echo "Maven Central API response: $HTTP_CODE"
51+
echo " Endpoint: /service/local/repositories"
52+
echo " Response: HTTP $REPO_CODE"
4653
47-
if [ "$HTTP_CODE" = "200" ]; then
48-
echo "status=SUCCESS" >> $GITHUB_OUTPUT
49-
echo "message=Maven Central connection successful" >> $GITHUB_OUTPUT
50-
echo "SUCCESS: Maven Central credentials are valid"
51-
elif [ "$HTTP_CODE" = "401" ]; then
52-
echo "status=FAILURE" >> $GITHUB_OUTPUT
53-
echo "message=Authentication failed - invalid credentials" >> $GITHUB_OUTPUT
54-
echo "ERROR: Maven Central authentication failed (401)"
55-
exit 1
56-
elif [ "$HTTP_CODE" = "403" ]; then
57-
echo "status=SUCCESS" >> $GITHUB_OUTPUT
58-
echo "message=Credentials valid (limited permissions on staging API is normal)" >> $GITHUB_OUTPUT
59-
echo "SUCCESS: Maven Central credentials valid (403 on staging API is acceptable for deployment)"
54+
if [ "$REPO_CODE" = "200" ]; then
55+
echo " ✅ Repository access verified"
56+
echo ""
57+
echo "✅ SUCCESS: Maven Central credentials are valid and working"
58+
echo "status=success" >> $GITHUB_OUTPUT
59+
exit 0
60+
elif [ "$REPO_CODE" = "401" ]; then
61+
echo " ❌ Authentication failed"
62+
elif [ "$REPO_CODE" = "403" ]; then
63+
echo " ⚠️ Authenticated but forbidden (may be OK)"
6064
else
61-
echo "status=FAILURE" >> $GITHUB_OUTPUT
62-
echo "message=Connection failed - HTTP $HTTP_CODE" >> $GITHUB_OUTPUT
63-
echo "ERROR: Maven Central connection failed with HTTP $HTTP_CODE"
64-
exit 1
65+
echo " ⚠️ Unexpected response: $REPO_CODE"
6566
fi
67+
echo ""
68+
69+
# Test 2: Try Nexus status endpoint (lightweight check)
70+
echo "Test 2: Checking Nexus status endpoint..."
71+
STATUS_CODE=$(curl -s -o /dev/null -w '%{http_code}' \
72+
-u "${{ secrets.OSSRH_USERNAME }}:${{ secrets.OSSRH_PASSWORD }}" \
73+
"https://oss.sonatype.org/service/local/status")
74+
75+
echo " Endpoint: /service/local/status"
76+
echo " Response: HTTP $STATUS_CODE"
77+
78+
if [ "$STATUS_CODE" = "200" ]; then
79+
echo " ✅ Status check passed"
80+
echo ""
81+
echo "✅ SUCCESS: Maven Central credentials are valid"
82+
echo "Note: Credentials work, but may have limited API access (normal for some endpoints)"
83+
echo "status=success" >> $GITHUB_OUTPUT
84+
exit 0
85+
elif [ "$STATUS_CODE" = "401" ]; then
86+
echo " ❌ Authentication failed"
87+
else
88+
echo " Response: HTTP $STATUS_CODE"
89+
fi
90+
echo ""
91+
92+
# Test 3: Check if it's a Central Portal token (new system)
93+
echo "Test 3: Checking Central Portal (new authentication system)..."
94+
CENTRAL_CODE=$(curl -s -o /dev/null -w '%{http_code}' \
95+
-H "Authorization: Bearer ${{ secrets.OSSRH_PASSWORD }}" \
96+
"https://central.sonatype.com/api/v1/publisher/status")
97+
98+
echo " Endpoint: central.sonatype.com/api/v1/publisher/status"
99+
echo " Response: HTTP $CENTRAL_CODE"
100+
101+
if [ "$CENTRAL_CODE" = "200" ]; then
102+
echo " ✅ Central Portal access verified"
103+
echo ""
104+
echo "✅ SUCCESS: New Central Portal credentials are valid"
105+
echo "status=success" >> $GITHUB_OUTPUT
106+
exit 0
107+
fi
108+
echo ""
109+
110+
# All tests failed
111+
echo "❌ FAILURE: All authentication tests failed"
112+
echo ""
113+
echo "Results:"
114+
echo " • Repository endpoint: HTTP $REPO_CODE"
115+
echo " • Status endpoint: HTTP $STATUS_CODE"
116+
echo " • Central Portal: HTTP $CENTRAL_CODE"
117+
echo ""
118+
echo "📝 Action Required:"
119+
echo " Your Maven Central credentials appear to be invalid or expired."
120+
echo " Maven Central is migrating to a new authentication system."
121+
echo ""
122+
echo " To fix:"
123+
echo " 1. Visit: https://central.sonatype.com/"
124+
echo " 2. Sign in and go to: Account → Generate User Token"
125+
echo " 3. Update GitHub secrets with new token credentials"
126+
echo ""
127+
echo "status=failure" >> $GITHUB_OUTPUT
128+
exit 1

0 commit comments

Comments
 (0)