Zero code coverage on new code if we do sonar analysis by latest commit of the Pull request

Must-share information (formatted with Markdown):

  • Sonar 9.9.1 & jdk17
  • Sonar analysis happen via Jenkins

User made multiple changes/commits on same pull request, each commit makes trigger build in jenkins.

one of the commit does not have the new code change and have a simple configure change. that time the sonar analysis has not consider the new code change on the previous commits. By that code coverage coming ZERO.

Please advise how to achieve this like read all the new code from branch instead of latest commit change.

Note: Input must be commit id & branch name.

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!


Welcome to the community!

So what you’re saying is: for the analysis of the config-only-commit, PR analysis only considered the changes in that commit, not changes in the overall PR?

Can you provide the analysis log corresponding to that commit?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.