This is a reproducer for the issue described in Sonar Community Forum.
Sonar Scanner Gradle ignores project properties when updating to version 4.3.1.3277.
In this example project the gradle.properties
file contains the following line:
dotenv.filename=.default.env
This is always referencing the .default.env
file, even if the dotenv.filename
environment variable is set to dev
or prod
.
In previous versions of Sonar Scanner Gradle this was working as expected.
- Gradle 8.1.1.
- Kotlin
- Terminal
- Tested on macOS 13.5.2
- Clone this repository
- Create a manual SonarCloud project on
sonarcloud.io
and transfer following properties to your project:ORGANIZATION KEY
from your Information pagePROJECT KEY
from your Information pageSONAR TOKEN
from the CI/CD integration page for GitHub Actions
- Set the following Sonar Properties in
build.gradle.kts
accordingly to your SonarCloud project:$YOUR_ORG
set toORGANIZATION KEY
$YOUR_PROJECT_KEY
set toPROJECT KEY
- For a successful run of the Sonar Scanner Gradle you need to following in your terminal:
$ export SONAR_TOKEN=(add here the SONAR TOKEN from your SonarCloud project)
$ touch .default.env
$ echo "FOO=default" > .default.env
$ ./gradlew sonar --stacktrace -Pdotenv.filename=./.default.env
$ rm .default.env
- For a failing run of the Sonar Scanner Gradle you need to following in your terminal:
$ export SONAR_TOKEN=(add here the SONAR TOKEN from your SonarCloud project)
$ touch .staging.env
$ echo "FOO=staging" > .staging.env
$ ./gradlew sonar --stacktrace -Pdotenv.filename=./.staging.env
$ rm .staging.env
Downgrade to 4.2.0.3129
and run again the steps from 5.