SonarQube gradle on CI

java
sonarqube

(Himanshu Walia) #1

Hi guys,
I am using below config on my root gradle file in a project with multiple module.
The problem this config does not work when run on the CI, on my local box (against doker) this scanes binaries fine.

any ideas ?

sonarqube {
properties {

    def thirdPartyLibs = buildscript.configurations.classpath.join(",")
    def libs = System.getenv('ANDROID_HOME') + "/platforms/android-28/android.jar" + "," + thirdPartyLibs


    property 'sonar.projectName', 'XX_XX_XX'
    property 'sonar.projectDescription', 'XX'
    property 'sonar.projectKey', 'android-XX'
    property 'sonar.projectVersion', app_version

    property "sonar.java.source", "1.7"
    property "sonar.sources", "src/main/java, src/main/java_legacy, src/main/kotlin"
    property "sonar.java.binaries", "build/intermediates/classes/release, build/tmp/kotlin-classes/release"
    property "sonar.java.libraries", libs
    property "sonar.scm.provider", 'git'
    
    property "sonar.tests", "src/test, src/test/kotlin"
    property "sonar.java.test.binaries", "build/intermediates/classes/test/release, build/tmp/kotlin-classes/release"
    property "sonar.junit.reportPaths", "build/test-results/**"
    property "sonar.test.libraries" , thirdPartyLibs

    property "sonar.java.coveragePlugin", "jacoco"
    property "sonar.jacoco.reportPaths", "build/jacoco/*.exec"
    property "sonar.android.lint.report", "build/reports/lint/lint-result.html"
    property "detekt.sonar.kotlin.config.path", "config/quality/detekt/detekt.yml"
    property "sonar.exclusions", "src/main/res/values/*,src/main/res/values-*/*,src/main/res/drawable/*,src/main/res/drawable-*/*,src/main/res_leagcy/**/*"
}

}

I also tried using
println buildDir

println “${buildDir}/intermediates/classes, ${buildDir}/tmp/kotlin-classes”
but no luck


(G Ann Campbell) #2

Hi,

If this runs successfully in one environment and not another the problem is likely in the environment itself. You should examine what the differences are between the two. If that doesn’t lead you to a fix, then when you come back here, you should bring the error message with you.

 
:slight_smile:
Ann


(Himanshu Walia) #3

Thanks, I will check what’s different in both env.

One question please, how does sonarQube handle / vs \. One difference is one machine is macbox and other is windows.

Perhaps on the windows machine its not finding any paths to binaries (hence no files being analyzed ) since i am using intermediates/classes/ forward slashes. Do I have to take care of this manually ?
Thanks


(G Ann Campbell) #4

Hi,

You’ve probably hit on the key difference on the first try! You do have to escape the backslashes in the path.

 
:slight_smile:
Ann