Setting Reference branch at a project settings level will display "This branch is configured to use itself as reference branch" for all branches

I am running Sonarqube 8.4.1 Developer edition
I set up New Code to use “Reference branch” and selected master which is my main branch as in the photo.
For each branch “Project settings” is selected and “Previous version” for master branch

After running the analisys on a newly created branch, the measure for the given branch displays the following text: “This branch is configured to use itself as reference branch. It will never have New Code.”

Can someone help me with some guidance? Maybe I’m doing something wrong or I’m missing some configuration.

Hi Costina,

i use this setting in a similar way and it works, see

After this project setting is done, every new branch != main branch should get the project setting
automatically, means master as reference.
The important thing is that main branch has to use previous version, it can not use itself as reference.

I have to use check for existence, create if not, set main branch as reference, set previous version for main branch every time, as it runs as part of a generic Jenkins pipeline that has to work for new and existing projects.


1 Like

Could you please post your scanner logs with debug enabled?

The scanner logs displayed: “SCM provider is disabled. No New Code will be computed.”.
SCM seems to be disabled by default. After enabling SCM everything seems to work as expected.
Thanks for the hint.

AFAIK, sonar.scm.disabled is false by default


Maybe it was given as analysis parameter with sonar.scm.disabled=true !?

It seems that the default value is true in SonarQube 8.4.1 image

Hm, it’s Sonarqube Enterprise official version 8.4.1 (build 35646) here.
Maybe there’s a difference between editions ?
Just checked with a fresh community edition on my machine and it has the same default
setting as shown in my screenshot.

The default value should be false. A lot of features in SonarQube rely on the SCM sensor being enabled. Maybe it had been set before the upgrade to 8.4.1?

Yes, but why Reset Default: True in his screenshot !?

Oh I missed that. To be honest, I don’t know how to explain that. I just tested and I also get False as the default.

Strange indeed and the default project scm setting is equal to the global setting.

Hi @Costina,

About the fact that you see that the default value of “Disable the SCM Sensor” is True => First of all, you only see this when you’re in the Settings of a Project. And you see this because in the global settings, this setting has been updated to “True”.
As a consequence, by default, in all of your projects, the SCM sensor will be disabled.

1 Like

I’m having similar symptoms (feature branches all report ‘using self as reference’ when configured to use main branch). I am using “Developer Edition Version 8.4.1 (build 35646)”

We build via Jenkins, which invokes Maven sonar plugin (via sonar:sonar). Our log shows this:
[2020-07-30T23:57:08.312Z] [INFO] Load New Code definition
[2020-07-30T23:57:08.312Z] [INFO] Load New Code definition (done) | time=44ms
[2020-07-30T23:57:08.312Z] [INFO] Computing New Code since fork with ‘develop’
[2020-07-30T23:57:08.312Z] [WARNING] Could not find ref: develop in refs/heads, refs/remotes/upstream or refs/remotes/origin
[2020-07-30T23:57:08.312Z] [WARNING] Branch ‘develop’ not found in git
[2020-07-30T23:57:08.312Z] [WARNING] Failed to detect fork date. No New Code will be computed.

After a bit of hunting around and experimenting, I see the problem.

We use the BitBucket Server plugin (bbs_checkout) to fetch the code in our pipeline. This plugin creates a ‘git-remote’ but with a name that matches the project-name in bitbucket. The sonar plugin is looking for the remote as ‘origin’. Neither plugin allows configuration (sigh!).

As a work-around, I did an explicit ‘git remote add …’ with the ‘origin’ name in my pipeline script (surrounded by a try/catch, cuz of course it fails the second time around). Seems a bit hokey, but fingers crossed, it works.


Thanks for sharing how you fixed it.
Unfortunately there are so many ways to clone and checkout a project that it’s hard for the scanner to always find the branches it needs. If the scanner can’t find the branches, we try to make it visible in the scanner logs and in the project’s dashboard so that it can be fixed. Any feedback on how to improve that is welcome.