We are using org.sonarqube gradle plugin to analyze our Java code and upload results to https://sonarcloud.io/ . Up to version 5.1 the plugin created a new project in sonarcloud when I was setting up a new java application.
After the upgrade to version 6.0.0.5145, the task runs fine, but no project is created in Sonar Cloud, so no results are uploaded.
After downgrading the plugin to 5.1.0.4882, the project was created, so I could continue using 6.0.0.5145 .
Is that intended? What must I change in my pipelines to get projects created automatically?
Or is it a bug?
Typically we see this error when sonar.branch.name or sonar.pullrequest.* is set (explicitly or via auto-configuration) and the project does not exist yet.
We have an internal ticket to solve this (provision project when branch configuration is provided), a feature already present in the SonarQube Server.
Are you sure this exact command is working with v5 of the Gradle plugin when the project doesn’t exist? Or could v5 have been working well absent the sonar.pullrequest.* parameters (it would be expected to fail with them)
To test this out, I used v6 of the Scanner for Gradle and had no problem auto-provisioning a project locally.
finally I found the root cause: Our pipeline already has a handling for the problem of not creating projects when sonar.branch.name or sonar.pullrequest.* or pullRequest parameters are set. If the build fails, it will run the command without any of these parameters to create the project.
The difference v5 vs v6 is (drum rolls): In v6 the build doesn’t fail on Could not find a default branch for project with key 'epa-dlt-watchdog'. Make sure project exists. while v5 does (see below)
Is that a bug to be fixed?
Using v6 ./gradlew --warning-mode all sonarqube -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=sda-se -Dsonar.qualitygate.wait=true -Dsonar.scm.provider=git -Dsonar.projectKey=epa-dlt-watchdog -Dsonar.token=**** -Dsonar.pullrequest.key=6 -Dsonar.pullrequest.base=main -Dsonar.pullrequest.branch=initial-quarkus-setup -Dsonar.pullrequest.provider=github -Dsonar.pullrequest.github.repository=**** -Dsonar.pullrequest.github.endpoint=https://api.github.com/ -Dsonar.exclusions= -Dsonar.coverage.exclusions=
Outcome:
Could not find a default branch for project with key 'epa-dlt-watchdog'. Make sure project exists.