Skip to content

Commit 99e20f4

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

1 file changed

Lines changed: 27 additions & 15 deletions

File tree

.github/workflows/credential-validation.yml

Lines changed: 27 additions & 15 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,40 @@ 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
44+
# Test Maven Central staging profiles endpoint (used during mvn deploy)
4145
HTTP_CODE=$(curl -s -o /dev/null -w '%{http_code}' \
4246
-u "${{ secrets.OSSRH_USERNAME }}:${{ secrets.OSSRH_PASSWORD }}" \
4347
"https://oss.sonatype.org/service/local/staging/profiles")
4448
45-
echo "Maven Central API response: $HTTP_CODE"
49+
echo "Endpoint: https://oss.sonatype.org/service/local/staging/profiles"
50+
echo "Response: HTTP $HTTP_CODE"
51+
echo ""
4652
53+
# Evaluate result
4754
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"
55+
echo "SUCCESS: Maven Central credentials are valid"
56+
echo "status=success" >> $GITHUB_OUTPUT
57+
exit 0
5158
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)"
59+
echo "❌ FAILURE: Authentication failed (HTTP 401)"
60+
echo "Credentials are invalid or expired."
61+
echo ""
62+
echo "Action required: Regenerate credentials at https://central.sonatype.com/"
63+
echo "status=failure" >> $GITHUB_OUTPUT
5564
exit 1
5665
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)"
66+
echo "❌ FAILURE: Access forbidden (HTTP 403)"
67+
echo "Credentials authenticated but lack necessary permissions."
68+
echo ""
69+
echo "Action required: Verify account has deployment permissions"
70+
echo "status=failure" >> $GITHUB_OUTPUT
71+
exit 1
6072
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"
73+
echo "FAILURE: Unexpected response (HTTP $HTTP_CODE)"
74+
echo "Unable to validate credentials."
75+
echo "status=failure" >> $GITHUB_OUTPUT
6476
exit 1
6577
fi

0 commit comments

Comments
 (0)