What's sonar baseline for feature branches

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension): SonarQube 7.9.1 EE, sonar-maven-plugin:3.6.0.1398

  • what are you trying to achieve:

Hello sonar community,

I’m using sonarQube 7.9.1 EE version for the jenkins multi-branch pipelines. I have a master branch as main branch and release(.*) as long live branches and all private branches as short lived branches which is correct. But, what would be the baseline for the private branches which got created from master and release branches?

I just wanted to know how to define a baseline when I created a private branch pipelines from release and master branches for the following scenarios?

scenario-1: I created a branch1 from master, how can I tell sonar that the baseline should take as master
scenarioe-2: I created a branch2 from release1, how can I tell sonar that the baseline should take as release1
scanerio-3: I created a branch3 from release2, how can I tell sonar that the baseline should take as release2

Currently, I’m passing sonar.branch.target parameter and value as master for the private branches which are getting created from master branch & release1 for the private branches which are getting created from release1 branch & release2 for the private branches which are getting created from release2 branch.

Is this correct what I’m currently doing for multi branch pipelines? if not, what’s the best way to provide baseline?

Also, I currently have “New Code Period” as “previous_version”

Hi,

Welcome to the community!

In 7.9 the baseline for a short-lived branch is the first analysis in the branch, IIRC. We’re aware that that doesn’t fit some real-life scenarios and we’ve done work since then to:

  • merge the short-lived and long-lived branch concepts
  • allow you to set one branch as the baseline for another.

To address your scenario in 7.9, you’d start by analyzing master as the first iteration on your branch (i.e. analyze master as sonar.branch.name=“my-slb”), and then start analyzing your branch.

So you know, the target branch is used for issues comparison, so that issues present on the target branch aren’t raised in the new branch. That’s it.

 
HTH,
Ann

1 Like

Thanks Ann!

I replied you very late but this is exactly what I’m doing in my sonar stage.

Appreciate your help!

Hi,

It’s not clear to me if there’s an outstanding / unanswered question here.

 
Ann

No, you answered to my question lol

1 Like