Update .gitea/workflows/sonar-scan.yaml
All checks were successful
SonarQube Analysis / Build, Test & Analyse (push) Successful in 3m29s
Build and Push to ACR / Build and Push (push) Successful in 6m15s

This commit is contained in:
2026-04-13 13:29:10 +00:00
parent 07c7ee316b
commit 9d36b5d5a1

View File

@@ -77,10 +77,10 @@ jobs:
- name: SonarQube analysis - name: SonarQube analysis
env: env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: | run: |
./mvnw -B sonar:sonar \ ./mvnw -B sonar:sonar \
-Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }} \ -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }} \
-Dsonar.projectName="Spring PetClinic" \ -Dsonar.projectName="Spring PetClinic" \
-Dsonar.host.url="${SONAR_HOST_URL}" \ -Dsonar.host.url="${SONAR_HOST_URL}" \
-Dsonar.token="${SONAR_TOKEN}" \ -Dsonar.token="${SONAR_TOKEN}" \
@@ -92,14 +92,14 @@ jobs:
- name: Quality Gate check - name: Quality Gate check
env: env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: | run: |
echo "Waiting for SonarQube to process the analysis..." echo "Waiting for SonarQube to process the analysis..."
STATUS="" STATUS=""
for i in $(seq 1 24); do # up to ~2 minutes for i in $(seq 1 24); do # up to ~2 minutes
RESPONSE=$(curl -sf \ RESPONSE=$(curl -sf \
-u "${SONAR_TOKEN}:" \ -u "${SONAR_TOKEN}:" \
"${SONAR_HOST_URL}/api/qualitygates/project_status?projectKey=${{ vars.SONAR_PROJECT_KEY }}" \ "${SONAR_HOST_URL}/api/qualitygates/project_status?projectKey=${{ secrets.SONAR_PROJECT_KEY }}" \
|| true) || true)
STATUS=$(echo "$RESPONSE" | python3 -c \ STATUS=$(echo "$RESPONSE" | python3 -c \
"import sys,json; print(json.load(sys.stdin)['projectStatus']['status'])" \ "import sys,json; print(json.load(sys.stdin)['projectStatus']['status'])" \
@@ -113,7 +113,7 @@ jobs:
echo "Quality Gate status: $STATUS" echo "Quality Gate status: $STATUS"
if [ "$STATUS" = "ERROR" ]; then if [ "$STATUS" = "ERROR" ]; then
echo "❌ Quality Gate FAILED — check ${{ vars.SONAR_HOST_URL }}/dashboard?id=${{ vars.SONAR_PROJECT_KEY }}" echo "❌ Quality Gate FAILED — check ${{ secrets.SONAR_HOST_URL }}/dashboard?id=${{ secrets.SONAR_PROJECT_KEY }}"
exit 1 exit 1
elif [ "$STATUS" = "OK" ]; then elif [ "$STATUS" = "OK" ]; then
echo "✅ Quality Gate PASSED" echo "✅ Quality Gate PASSED"