- ALM used Bitbucket Cloud
- CI system used jenkins Multibranch Pipeline
We’re using the following versions of SonarCloud:
Below is the command we using for sonar analysis
sonar-scanner -X -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=passing-the-organization -Dsonar.projectBaseDir=./path/to/basedir -Dproject.settings=./sources/sonar-project.properties -Dsonar.scanner.metadataFilePath=$(pwd)/report-task.txt -Dsonar.ws.timeout=600 -Dsonar.projectKey=project-key -Dsonar.pullrequest.branch=branch -Dsonar.pullrequest.key=26163 -Dsonar.pullrequest.base=develop -Dsonar.token=****
below are properties we are passing through sonar-project.properties file
sonar.exclusions=wildcard entries of exclusions
sonar.coverage.exclusions=wildcard entries of coverage exclusions
we are not observing any errors in the sonar analysis execution logs except the java 11 usage warning. But the coverage is not getting showing in the quality gate summary of sonarcloud only for the PR analysis and other metrics like bugs, code smells, duplications are populating fine. with same setup we could able to see the coverage for branch analysis. PFB Screenshots
It looks like new lines aren’t being detected in your pull request the same as in your short-lived branch analysis (although based on the estimated after merge figure, the coverage report is being read just fine).
What value is being used for
sonar.branch.target in your short-lived branch analysis? Is it the same as the PR analysis (targeting
develop) or could it possibly be set to some other value like
In the PR you raised on Bitbucket, does the diff contain the same files/lines as the Code tab of your short-lived branch analysis?
Yes for our short lived branch’s also the coverage is not showing and it is targeted to develop (main) branch only, But in this project we don’t use the short-lived branch’s. For PR’s not only PR’s to develop and also for other long-lived branch also not showing the coverage.
For PR analysis and Short-lived branch analysis it is not showing anything in the code tab even there are changes in code. PFB SS’s
What do the logs say about detecting changed files/lines?
DEBUG level logs may help as well (
12:41:18.612 INFO: SCM collecting changed files in the branch
12:41:18.853 INFO: SCM collecting changed files in the branch (done) | time=241ms
12:41:18.853 DEBUG: SCM reported 0 files changed in the branch
12:53:30.951 DEBUG: SCM revision ID 'ef59fea67a9a6b4e6ed8a94411fffff7b72e0f3f'
12:53:31.006 INFO: SCM writing changed lines
12:53:31.007 DEBUG: loading config FileBasedConfig[/proj/jenkins/.config/jgit/config]
12:53:31.030 DEBUG: Merge base sha1: d928d2561a496207fff30bcbe888ecaf1a29e2f6
12:53:31.031 DEBUG: SCM reported changed lines for 0 files in the branch
12:53:31.031 INFO: SCM writing changed lines (done) | time=25ms
Any warnings, informational messages, unexpected results? It would be useful to compare the logs of the short-lived branch to the pull request analysis.
I could see below debug logs in only the PR analysis where as in long-lived branches I don’t those messages.
06:55:25.890 DEBUG: SCM reported 3 files changed in the branch
06:57:23.759 DEBUG: SCM reported changed lines for 0 files in the branch
the above both the messages are from same pipeline and there are no warnings and error messages in the debug logs. Could you please help on this.
Could you please help here, like are we missing any required parameters
I’m not really sure where to go from here. I think it would make sense for you to attach your full DEBUG analysis logs from your Jenkins pipeline (including the full jenkins pipeline logs, like the git checkout)