Jenkins CI driven sonarQube analysis reporting 0 scanned files

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)

  • SonarQube Version 9.3 (build 51899)

  • Jenkins 2.346.2 (https://www.jenkins.io/)

  • maven-3.6.3

  • org.sonarsource.scanner.maven:sonar-maven-plugin:jar:3.9.1.2184

  • Pull request based SonarQube analysis

  • launching the PR analysis through mvn command
    mvn sonar:sonar -X -Dsonar.verbose=true -Dsonar.java.source=8 -Dsonar.projectKey=PRJ_XYZ -Dsonar.pullrequest.key=107 -Dsonar.pullrequest.branch=feature/badcode -Dsonar.pullrequest.base=master

In the logs, we notice that the PR pull request is recognized against the correct source and target branches. But, the SCM somehow only shows 0 changed files even though there is a one changed file.

[INFO] 15:00:00.586 Pull request 107 for merge into master from feature/badcode
[INFO] 15:00:00.605 SCM collecting changed files in the branch
[INFO] 15:00:00.762 Merge base sha1: 4b548fb41005805e5c0aca462732efbda0cf78b0
[INFO] 15:00:00.790 SCM collecting changed files in the branch (done) | time=187ms
[DEBUG] 15:00:00.791 SCM reported 0 files changed in the branch

Also wanted to point out that the below command works, if ran locally.

mvn sonar:sonar -Dsonar.host.url=HTTPS_URL_TO_MY_SONAR -Dsonar.login=XXXXXX -Dsonar.projectKey=PRJ_XXXXXX -Dsonar.pullrequest.key=107 -Dsonar.pullrequest.branch=feature/badcode -Dsonar.pullrequest.base=master

Hi,

Welcome to the community!

Would you care to share your analysis log?

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

This guide will help you find them.

 
Ann

Hello Ann,

Thanks for your reply. I was able to troubleshoot this further and turned out that Jenkins pipeline was not accurately set up to checkout the correct branch. Once, we fixed the pipeline, we were able to see the right set of changed files.

1 Like