Fix: Update CI workflow to enhance playbook syntax checking and improve SonarQube connectivity verification
Some checks failed
CI / lint-and-test (pull_request) Successful in 58s
CI / ansible-validation (pull_request) Successful in 2m15s
CI / secret-scanning (pull_request) Successful in 54s
CI / dependency-scan (pull_request) Successful in 58s
CI / sast-scan (pull_request) Successful in 2m11s
CI / license-check (pull_request) Successful in 54s
CI / vault-check (pull_request) Successful in 1m54s
CI / playbook-test (pull_request) Successful in 1m52s
CI / container-scan (pull_request) Successful in 1m27s
CI / sonar-analysis (pull_request) Failing after 50s
CI / workflow-summary (pull_request) Successful in 50s

This commit is contained in:
ilia 2025-12-14 20:43:28 -05:00
parent f20b671e76
commit e54ecfefc1

View File

@ -218,8 +218,11 @@ jobs:
fi
done
if [ $failed -eq 1 ]; then
echo "Some playbooks have errors (this is expected without inventory/vault)"
exit 0
echo "❌ Some playbooks have syntax errors!"
echo "Note: This may be expected if playbooks require inventory/vault, but syntax errors should still be fixed."
exit 1
else
echo "✅ All playbooks passed syntax check"
fi
continue-on-error: true
@ -287,13 +290,32 @@ jobs:
- name: Check out code
uses: actions/checkout@v4
- name: Verify SonarQube connection
run: |
echo "Checking SonarQube connectivity..."
if [ -z "$SONAR_HOST_URL" ] || [ -z "$SONAR_TOKEN" ]; then
echo "❌ ERROR: SONAR_HOST_URL or SONAR_TOKEN secrets are not set!"
echo "Please configure them in: Repository Settings → Actions → Secrets"
exit 1
fi
echo "✓ Secrets are configured"
echo "SonarQube URL: ${SONAR_HOST_URL}"
echo "Testing connectivity to SonarQube server..."
if curl -f -s -o /dev/null -w "%{http_code}" "${SONAR_HOST_URL}/api/system/status" | grep -q "200"; then
echo "✓ SonarQube server is reachable"
else
echo "⚠️ Warning: Could not verify SonarQube server connectivity"
fi
- name: Run SonarScanner
run: |
echo "Starting SonarQube analysis..."
sonar-scanner \
-Dsonar.projectKey=ansible-infra \
-Dsonar.sources=. \
-Dsonar.host.url=${SONAR_HOST_URL} \
-Dsonar.login=${SONAR_TOKEN}
-Dsonar.login=${SONAR_TOKEN} \
-X
continue-on-error: true
workflow-summary: