Problem disabling gradle.build detection on Github action for Monorepo

Error message

Gradle project detected. You should use the SonarQube plugin for Gradle during build rather than using this GitHub Action.

Summary

We don’t want to use the SonarQube plugin for Gradle because we have a multi-language repository and we want to scan everything in the repository not just the Gradle applications.

As mentioned in the thread above, it should be tried to exclude the build.grade file in the sonar-project.properties file.

I have tried this with all possible exclusion variations, but still get the same error.

The sonar-project.properties file:

sonar.organization=*******
sonar.projectKey=********_*****-******
sonar.host.url=https://sonarcloud.io

sonar.sourceEncoding=UTF-8
sonar.exclusions=**/build.gradle,build.gradle,/build.gradle,./build.gradle,*build.gradle
sonar.test.exclusion=**/build.gradle,build.gradle,/build.gradle,./build.gradle,*build.gradle

Hi,

Welcome to the community!

The SonarScanner for Gradle will absolutely do this. You just need to set sonar.sorces=.

 
HTH,
Ann

2 Likes

Hi Ann,

Thanks for the tip.

I added “sonar.sources=.” to the sonar-project.properties file, but it still doesn’t work.
I still get the error: “Gradle project detected. You should use the SonarQube plugin for Gradle during build rather than using this GitHub Action.”

Best Regards

Hi,

SonarScanner for Gradle isn’t going to read the sonar-project.properties file. You need to set it on the command line or in your build file.

 
HTH,
Ann

Hi,

Maybe you misunderstood me. I want to use the SonarCloud Github action and not the Gradle plugin. But when i try to use the github action it finds the grade.build file, it fails and suggests me to use the gradle plugin. As I understood I need to exclude the file build.gradle in the Sonarcloud properties file that is called from the Github action job. I have already done that but the github action still detects it.

Thank you

Hi,

I can’t tell you how to change the behavior of the action. It’s refusing to run and telling you to use SonarScanner for Gradle. So that’s what you need to do. I was trying to help you accomplish the underlying goal of analyzing all the files.

In the end, all the scanner implementations call the same underlying executable.

 
HTH,
Ann