diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml index 92c0135..f613dc9 100644 --- a/.github/workflows/qa.yml +++ b/.github/workflows/qa.yml @@ -141,4 +141,21 @@ jobs: - name: Assert run: | ./test/assertFileContains ./output.properties "sonar.verbose=true" - + overrideSonarcloudUrlTest: + name: > + 'SONARCLOUD_URL' is used + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Run action with debug mode + uses: ./ + with: + args: -Dsonar.scanner.internal.dumpToFile=./output.properties + env: + SONARCLOUD_URL: "http://mirror.sonarcloud.io" + SONAR_TOKEN: FAKE_TOKEN + - name: Assert + run: | + ./test/assertFileContains ./output.properties "sonar.scanner.sonarcloudUrl=http://mirror.sonarcloud.io" diff --git a/Dockerfile b/Dockerfile index 05ec9e7..3cc91c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -FROM sonarsource/sonar-scanner-cli:11.0 +FROM sonarsource/sonar-scanner-cli:11.1 -LABEL version="3.0.0" \ +LABEL version="3.1.0" \ repository="https://github.com/sonarsource/sonarcloud-github-action" \ homepage="https://github.com/sonarsource/sonarcloud-github-action" \ maintainer="SonarSource" \ diff --git a/entrypoint.sh b/entrypoint.sh index 9cd1c40..f19340f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,8 @@ #!/bin/bash -set -e +set -eo pipefail + +declare -a args=() if [[ -z "${SONAR_TOKEN}" ]]; then echo "Set the SONAR_TOKEN env variable." @@ -17,14 +19,16 @@ if [[ -f "${INPUT_PROJECTBASEDIR%/}/build.gradle" || -f "${INPUT_PROJECTBASEDIR% to get more accurate results." fi -if [[ -z "${SONARCLOUD_URL}" ]]; then - SONARCLOUD_URL="https://sonarcloud.io" +if [[ -n "${SONARCLOUD_URL}" ]]; then + args+=("-Dsonar.scanner.sonarcloudUrl=${SONARCLOUD_URL}") fi -debug_flag='' if [[ "$RUNNER_DEBUG" == '1' ]]; then - debug_flag=' --debug ' + args+=("--debug") fi unset JAVA_HOME -sonar-scanner $debug_flag -Dsonar.projectBaseDir=${INPUT_PROJECTBASEDIR} -Dsonar.host.url=${SONARCLOUD_URL} ${INPUT_ARGS} + +args+=("-Dsonar.projectBaseDir=${INPUT_PROJECTBASEDIR}") + +sonar-scanner "${args[@]}" ${INPUT_ARGS}