SonarQube analyze for short-lived branches doesn't work

(Norbert) #1


I am facing an issue with empty analyze of short-lived branch.
We are using Jenkins to trigger a job, branch is being created inside the project, however it looks like it is empty.

Similar issue:

It works fine for long-lived branches.

It is same with passed in build or skipped.

Analyze is performed, files are being chosen into the analyze, but nothing visible in the UI.

INFO - CPD calculation finished
INFO - SCM writing changed lines
INFO - SCM writing changed lines (done) | time=2ms
INFO - Analysis report generated in 191ms, dir size=137 KB
INFO - Analysis report compressed in 6ms, zip size=21 KB
INFO - Analysis report uploaded in 358ms
INFO - ANALYSIS SUCCESSFUL, you can browse https://xxxx/dashboard?id=xxxx&branch=xxxx&resolved=false
INFO - Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO - More about the report processing at https://sxxxx/api/ce/task?id=xxxx
INFO - Analysis total time: 18.875 s

(Luca Ippolito) #2

Yesterday, i posted a Question here as well about a similar issue. Does my description of the problem match with that what you are experiencing?

(Norbert) #4

Thank you for your reply, but my issue seems to be different. In this case short-lived branch has been created, but not analyzed (no files, no bugs reported).

(Janos Gyerik) #6

Can you please clarify what you mean by “looks like it’s empty”, and “nothing visible in the UI”?
For example, what do you see when you go to the Code tab on SonarQube?

Also, can you please run the scan in debug mode (use -X flag), and look for lines in the output like this:

[INFO] 11:36:32.749 SCM provider for this project is: git
[INFO] 11:36:32.749 2 files to be analyzed
[DEBUG] 11:36:32.759 Blame file some/path/...
[DEBUG] 11:36:32.759 Blame file another/path/...

The files mentioned by the “Blame file” lines are the ones detected as changed in the branch, relative to the specified If there are no such lines, then it’s no surprise if the analysis appears to be empty. And then, I would check the output of git diff --name-only the/target/branch... (the 3 dots at the end is not a typo). If this last command gives empty output, then the current branch has nothing new compared to the target, and therefore it’s expected that the analysis is empty.

Let me know your findings. If the above doesn’t help to understand what’s happening, then please include:

  • a more complete snippet of the scanner output
  • the exact scan command used, with all its parameters
  • how do you checkout the branch before running the analysis: shallow clone?