Pull Decoration Not happening

Hi ,. I have already configured SonarQube with Github for Pull Request DEcoration.

file type = .xaml

SonarQube is able to detect the bugs , code smells whenever i create a pull request from a development branch to master branch.

WE have recently introduced one more branch - master-UAT which is our branch for UAT environment. If the pull request is created from Development branch to Master-UAT branch.the PR decoration is happening and however there is no bugs/code smells being detected. Though i can see the complete code in the particular pull request , the number of lines varies . Is there anything that needed to done so that the complete file can be analyzed ?

however , i can see a new information that pops up in the console.

INFO: The base branch ‘master-UAT’ is only analyzed as a pull request. Using its base instead: ‘master’

You’ll only see issues (bugs/code smells) in a pull request if they don’t already exist in its target branch. So perhaps the issues you were expecting to see already exist in ‘Master-UAT’?

A few screenshots would help understand what you’re getting vs what you were expecting to get.

Thanks Duarte …!

So my repo will have two branches for release , one for test and one for production. For development we will be creating a new branch each time .

Here the issue is , Jenkins will do the sonar scanning for the respective branches.
But first time , when i push my development branch for scanning, it always returns 0 . ref image 2

I can see this particular warning . However, i am doing only the analysis for my development branch as Short lived branch

  1. Could not find ref ‘master’ in refs/heads, refs/remotes/upstream or refs/remotes/origin. You may see unexpected issues and changes. Please make sure to fetch this ref before pull request analysis.

3)

Pull request analysis is completed successfully but there is no code smells/bugs detected

All the branches and pull requests are getting analysed properly and identifying code smells and bugs , if i scan the master branch first and then scan the remaining branches.

Regarding the following warning:

Could not find ref ‘master’ in refs/heads, refs/remotes/upstream or refs/remotes/origin. You may see unexpected issues and changes. Please make sure to fetch this ref before pull request analysis.

This means that Jenkins is only fetching the pull request from git, and that the master branch is not available in the local git clone. Because of that, the SonarQube scanner is not able to find master and to compute the diff between the P/R being analyzed and master.
Check how Jenkins is cloning the git repository. It shouldn’t be done with --single-branch, for example.

2 Likes

I have the same issue with teamcity. Any idea how this can be solved in teamcity environment?

Please see my last post.
With team city it’s the same thing: check the first step where it clones and checks out the project and make sure that all branches (or at least the target branch) is being fetched and is present locally.