run the scanner command above (only test only for fast feedback): ./gradlew core:test --tests '*ExceptionsTest' core:jacocoTestReport sonar --rerun --info
Analysis is visible in SonarCloud as master branch. So far, so good!
Add support for branch analysis as mentioned in docs (Branch analysis setup & SonarCloud) as below (hardcoded to omit any possible error related to environment variables)
sonar {
properties {
property "sonar.sourceEncoding", "UTF-8"
property "sonar.projectKey", "jobrunr_jobrunr"
property "sonar.organization", "jobrunr"
property "sonar.branch.name", "v7" // simulate branch v7 by hardcoding it
property "sonar.branch.target", "master" // also tried v7 instead of master. Why do I even need to set this variable? I just want analysis for branch v7...
property "sonar.coverage.jacoco.xmlReportPaths", "/tmp/reports/$project.name/jacocoTestCoverage.xml"
}
}
run the scanner command above (only test only for fast feedback): ./gradlew core:test --tests '*ExceptionsTest' core:jacocoTestReport sonar --rerun --info
only 1 branch available in SonarCloud
I expect to have 2 branches after the last analysis.
I had SonarCloud working with v3.5 but needed to upgrade and to be honest, I think the developer experience is not that great. I took me already almost 2 days and I’ve even deleted my SonarCloyd project (300 issues I need to revisit again ) to try to get this to work (sorry for the venting).
Back then I was working and doing Sonar analysis on the next release branch, v7. And, the values for DRONE_BRANCH and DRONE_SOURCE_BRANCH were the same. Hence, I choose the easiest one for me .
I just tried a printenv and these are the results now for a build that is running a PR. We only do Sonar analysis on the master and v7 branch (so not each PR) so my guess will be that when I launch the sonar analysis, it will have DRONE_BRANCH= v7.
Ultimately, I cloned your repo and the v7 branch and created a project in my personal SonarCloud organization. I changed the build.gradle values to connect to my org and my project and when I ran analysis… the results uploaded to your project.
So that makes me think that nothing in the sonar block of your build.gradle is impacting your build. So where is it getting the values from?
Well, it looks like they’re in your gradle.properties for the project.