From 7830ac5e0deca8d933b7aa3d2f276f7dbb0afde4 Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Sat, 28 Mar 2026 17:28:59 +0100 Subject: [PATCH] fix(ci): validate SONAR_HOST_URL before running scanner Fail early with a clear message if the variable is missing or lacks an http(s) scheme. Co-Authored-By: Claude Opus 4.6 (1M context) --- .gitea/workflows/sonarqube.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitea/workflows/sonarqube.yml b/.gitea/workflows/sonarqube.yml index 3aaa215..4e7754c 100644 --- a/.gitea/workflows/sonarqube.yml +++ b/.gitea/workflows/sonarqube.yml @@ -46,6 +46,10 @@ jobs: SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | + if [ -z "$SONAR_HOST_URL" ] || ! echo "$SONAR_HOST_URL" | grep -qE '^https?://'; then + echo "::error::SONAR_HOST_URL is missing or invalid (got: '$SONAR_HOST_URL'). Set it as a repo variable with full URL (e.g. https://sonar.example.com)." + exit 1 + fi sonar-scanner \ -Dsonar.host.url="$SONAR_HOST_URL" \ -Dsonar.login="$SONAR_TOKEN" \