- SonarQube version : 3.2.0
- Sonar-scanner : 3.1.0
Hi, I’m i new to sonarqube and was task to add sonarcloud to our bitbucket pipeline. I decided that i wanted to be able to run it locally first before adding it to the pipeline. I have a gradle multi-project structure and i want every gradle subproject to be their own project. ATM, if i run the scan and go to localhost:9000, i see project MyApp and the code of subapp1 & subapp2 are included in that project. What i want is to have a project for each so that we see subapp1 and subapp2 as two projects.
This is my project structure
MyApp
|—subapp1
| |—gradle.build
|—subapp2
| |—gradle.build
|—
|—build.gradle
|—setting.gradle
myApp/settings.gradle
rootProject.name = 'myApp'
include 'subapp1', 'subapp2'
myapp/build.gradle
sonarqube {
properties {
property "sonar.projectKey", "subapp1"
property "sonar.host", "http://localhost:9000"
property "sonar.name", "subapp1"
property "sonar.login", "myToken"
}
}
myapp/subapp1/build.gradle
sonarqube {
properties {
property "sonar.projectKey", "subapp1"
property "sonar.host", "http://localhost:9000"
property "sonar.name", "subapp1"
property "sonar.login", "myToken1"
}
}
myapp/subapp2/build.gradle
sonarqube {
properties {
property "sonar.projectKey", "subapp2"
property "sonar.host", "http://localhost:9000"
property "sonar.name", "subapp2"
property "sonar.login", "myToken2"
}
}
I used this article as a guide: SonarScanner for Gradle | SonarQube Docs
I think it looks into MyApp/build.gradle first and skip my MyApp/subapp1/build.gradle & MyApp/subapp2/build.gradle. I think that’s the case because if i comment out the sonarqube part of the MyApp/build.gradle i get the following error.
Execution failed for task ':sonarqube'.
> Not authorized. Analyzing this project requires authentication. Please provide a user token in sonar.login or other credentials in sonar.login and sonar.password.
ATM i use the following command at the root of the project to start the scan ./gradlew sonarqube
So, my question is, how can i run analysis on subapp1 & subbapp2 as 2 separate project? I feel like i’m not far off.