sonar.branch.name=$BRANCH_NAME and sonar.branch.target=master
Java - Sprint Boot
the SonarCloud coverage reports generated on our pull requests have 0 lines covered when we follow the report towards its details page. I’ve noticed that none of the short-lived branches had any lines that were covered. Even if we introduce vulnerabilities or code smells on purpose, neither branch or PR analysis are picking this up.
Just to be clear about what you mean — do you mean that on the analyses of short-lived branches and pull requests, no files appear in the Code tab on SonarCloud?
Thank you for the response!
Yes, that is correct and that’s probably also the reason why vulnerabilities, code smells, code coverage and so on are not displayed and picked up on branch and PR analysis.
I think it’s time to look in the scanner logs (preferably at DEBUG level, by adding -X to the scanner command or setting the analysis parameter sonar.verbose=true to see if anything is off. Here are the kind of logs you should be looking for on a branch/PR analysis.
# Check if there are any errors collecting changed files
INFO: SCM collecting changed files in the branch
....
INFO: SCM collecting changed files in the branch (done) | time=324ms
DEBUG: SCM reported 1 file changed in the branch
# Make sure all files you expect to be analyzed are being analyzed and aren't ignored
INFO: 15 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: 0 files ignored because of scm ignore settings
# Make sure the git repository is being detected
INFO: SCM Publisher SCM provider for this project is: git
INFO: SCM Publisher 1 source file to be analyzed
# Check if there are any errors collecting changed lines
DEBUG: SCM reported changed lines for 1 file in the branch
INFO: SCM writing changed lines (done) | time=59ms
Checking for any WARN messages in the logs would also be a good step.
I’ve been digging for the last couple of days and it’s starting to look a lot like the problem here. If i trigger an analysis locally it reports the short lived branch. Whenever i trigger it from cloudbuild (with the same parameters) it does nothing.