Fix: Enhance SonarScanner error handling in CI workflow with detailed failure messages and troubleshooting guidance
All checks were successful
CI / lint-and-test (pull_request) Successful in 57s
CI / ansible-validation (pull_request) Successful in 2m20s
CI / secret-scanning (pull_request) Successful in 53s
CI / dependency-scan (pull_request) Successful in 58s
CI / sast-scan (pull_request) Successful in 2m14s
CI / license-check (pull_request) Successful in 55s
CI / vault-check (pull_request) Successful in 2m9s
CI / playbook-test (pull_request) Successful in 2m4s
CI / container-scan (pull_request) Successful in 1m27s
CI / sonar-analysis (pull_request) Successful in 2m5s
CI / workflow-summary (pull_request) Successful in 51s

This commit is contained in:
ilia 2025-12-14 21:35:52 -05:00
parent 699aaefac3
commit dc94395bbc

View File

@ -391,12 +391,26 @@ jobs:
- name: Run SonarScanner
run: |
echo "Starting SonarQube analysis..."
sonar-scanner \
-Dsonar.projectKey=ansible-infra \
if ! sonar-scanner \
-Dsonar.projectKey=ansible \
-Dsonar.sources=. \
-Dsonar.host.url=${SONAR_HOST_URL} \
-Dsonar.login=${SONAR_TOKEN} \
-X
-X; then
echo ""
echo "❌ SonarScanner analysis failed!"
echo ""
echo "Common issues:"
echo " 1. Project 'ansible' doesn't exist in SonarQube"
echo " → Create it manually in SonarQube UI"
echo " 2. Token doesn't have permission to analyze/create project"
echo " → Ensure token has 'Execute Analysis' permission"
echo " 3. Token doesn't have 'Create Projects' permission (if project doesn't exist)"
echo " → Grant this permission in SonarQube user settings"
echo ""
echo "Check SonarQube logs for more details."
exit 1
fi
continue-on-error: true
workflow-summary: