Hello,
I am a new user of SonarQube and I am trying to deploy it through Gitlab.
I am using gitlab-runner 15.5.0 with SonarScanner 4.8.0.2856 and trying to analyze an Android project that has the following structure:
/<repository-name>
/src
| /androidTest (root folder for Android instrumentation test sources and resources)
| | /java (root folder for instrumented Java test classes)
| | /kotlin (root folder for instrumented Kotlin test classes)
| | /resources (root folder for instrumented test resources)
| /docs (root folder for all technical documentation files)
| | /asciidoc (root folder for all Asciidoc source files including plantuml diagrams and images)
| /main (root folder for all module sources and resources)
| | /aidl (root folder for Android IPC interface definitions)
| | /java (root folder for Java implementation classes and interfaces)
| | /kotlin (root folder for Kotlin implementation classes and interfaces)
| | /res (root folder for Android resources)
| | /resources (optional root folder for resources in case of a common JAR lib)
| /test (root folder for all test sources and resources)
| | /java (root folder for Java unit test classes)
| | /kotlin (root folder for Kotlin unit test classes)
| | /resources (root folder for test resources)
I am having two stages in my pipeline, one that builds the project and creating the artifacts and one responsible for scanning the project:
If you’re already using Gradle to build your code, I suggest using the SonarScanner for Gradle to analyze it. It save lot of manual (error-prone) configuration.
Thanks for your reply. I suppose that, then the build.gradle file will contain all of these properties that were put on the sonar-project.properties file. Something like this:
You should really not need to set anything more than sonar.projectKey and sonar.projectName. The rest that you list (except sonar.qualitygate.wait) either don’t exist, or are handled by the Scanner for Gradle itself.
Yes – but it should be done in the same context as gradle build (so that information from the build is avalible to gradle sonarqube)
i have set the sonar.projectKey and sonar.projectName (only those) in build.gradle as you suggested but the message I receive from gradle test sonar command in Gitlab CI is the following:
Please, make sure your "sonar.junit.reportPaths" property is configured properly
Resource not found: com.sammy.service.JavaFareTest under the directory /Users/samuelifere/IdeaProjects/codingChallenges while reading test reports. Please, make sure your "sonar.junit.reportPaths" property is configured properly
Resource not found: com.elektrobit.aak.aakeb.LanguageLayoutsTest under the directory /builds/aak/aak while reading test reports. Please, make sure your "sonar.junit.reportPaths" property is configured properly
Resource not found: com.elektrobit.aak.aakeb.SampleJavaUnitTest under the directory /builds/aak/aak while reading test reports. Please, make sure your "sonar.junit.reportPaths" property is configured properly
The thing is that this message is shown when i add sonar task in the gradle command. For example,
gradle clean check sonar or gradle clean test sonar. if sonar task is not added, the i don’t see the message.
My next question regards instrumentation tests on emulator. I run gradle connectedAndroidTest but i see no coverage exported on SonarQube. For unit Tests i can see coverage but not for instrumented android tests.