sonar.newCode.referenceBranch | no infos


Sonarqube 9.4 developer Edition
SonarScanner 4.7

I use the parameter “sonar.newCode.referenceBranch” and apparently it works. Why can’t I see any information about the successful setting anywhere?

When I set the “New code Period” in sonarqube 8.9.2 via the GUI, I see the corresponding setting in the Jenkins log and in Sonarqube.
2022-05-27 13_10_47-Window

2022-05-27 13_45_23-Window



I guess you’re expecting to see the reference branch listed under the “New Code” label on the tab? This is a great point. I’ve referred it to the team.


Excuse me, could someone explain for me how referenceBranch property works ?

What I’m expecting is to be able to run analysis on my branch once to be able to detect my new code report … but what I’m getting is I have to run the branch twice … one time for the overall code and other one for the new code .

is there any way to have a report for only new code with one time analysis ?


Hi Salma,

I really don´t understand what you mean.

Why you have to build your branch twice? One build for the new and overall code!


Hi Mark,

thanks for your response.

ok let me explain more … the default behaviour for sonar is:
when I analyze a branch for the first time … the result will be an analysis for the overall code, and if you want to analyze only your new code … you’ll need to run analysis again to detect the new code.
( as the default project setting is previous version )

My question is … Is there any way to run analysis on my new branch just one time and display an analysis for my new code only ?
( I expect to see a result on sonar as the one that we get when anlayze a pull request )

kindly note that I’ve updated the new code definition from sonar properties file to be referenceBranch … but it didn’t work with me and analyzed the branch as the default ( previous version )

Hi @markluebbehuesen,

We no longer compute the date when using a reference branch to determine a new code period, as this is ever-changing and tricky to get right. However, we should still display “Compared to …” in the tab. This is a regression and will be fixed by: [SONAR-17041] Add missing reference branch name in new code tab - SonarSource

@Salma_Hassan Could I ask you to open another thread for such questions? It doesn’t relate to the original question, and this can make it hard to follow what’s going on. In any case, the answer is no: you cannot achieve this using only a single analysis. You will always have to first analyze your reference branch to determine the Overall code. So, a minimum of 2 analyses. This is true regardless of the new code strategy you use (reference branch, version, date, etc).

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.