Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sonarqube branch results for long-lived branch not showing as expected

Sonarqube Server Version 7.0 (build 36138)

Sonarqube Branch Plugin 7.0 (build 413)

sonar-maven-plugin:3.4.0.905

Java project

Sonarqube is set up with a master branch already.

As part of a Jenkins build job we execute the following command:

mvn sonar:sonar -Dsonar.host.url=<our host> -Dsonar.projectName=<project name> -Dsonar.projectKey=<project name> -Dsonar.branch.name=${BRANCH}

where BRANCH is set to the branch name we are building in Jenkins.

Analysis appears to work when we build our "develop" branch in that the develop branch appears if it isn't in Sonarqube and the timestamp for the analysis is correct on the server, but there are two issues:

1) I've set "develop" to be a long-lived branch per the instructions in https://docs.sonarqube.org/display/PLUG/Branch+Plugin by modifying the long-lived branch regex in the SQ server to be:

(branch|release|develop)-.*

but I only see the Issues and Code tabs on the "develop" branch display. And in the Jenkins job, I see the message:

[INFO] Branch name: develop, type: short living

which leads me to believe that develop is not being recognized as a long living branch.

2) There is no output in the Issues tab. Only the code tab shows anything. But the master branch output shows 225 issues, so I would expect the same list of issues in the develop branch (since they haven't been addressed).

Questions:

  1. Do long living branches show all of the same output that you normally see for the master branch, including "Overview"?

  2. Is there something that I need to do to specify the "develop" branch as long-living in the maven command above?

  3. Any idea why the issues tab doesn't show anything?

Many thanks, Wes

like image 607
Wes Gamble Avatar asked Jun 14 '18 21:06

Wes Gamble


People also ask

How do you make a branch long lived in Sonarqube?

On your project, go to Administration / Branches & Pull Requests. There, you will see in the top-right corner a text like this: "Long living branches pattern: (branch|release)-. * ". That means that when the name of the branch starts with branch- or release- , then it will be considered a long-living branch.

How do I specify a branch in Sonarqube?

Starting in Developer Edition, your main branch can be renamed from the project settings at Project Settings > Branches and Pull Requests.

How do I change the default branch in Sonarcloud?

It's currently not possible to “select” which branch is the default one. However, you can rename your default branch to whatever you want. For instance, you can rename “master” to “develop”.

How do I delete a master branch in Sonarqube?

You can delete a branch in the Branches tab at Project Settings > Branches and Pull Requests.


2 Answers

In my opinion it is your regex you should check first. You are using the default (branch|release|develop)-.* notice that you have added hyphen(-) at the end.
So, sonar expects the branch name to be branch-, release- or develop-. In your case I believe the regex should be (branch|release|develop).*

like image 139
Aman Avatar answered Sep 22 '22 13:09

Aman


Seems you hit this:
There's already a Jira ticket
https://jira.sonarsource.com/browse/MMF-1265
https://community.sonarsource.com/t/long-lived-branches-quality-gate-does-not-fail-in-first-analysis/175

like image 24
Rebse Avatar answered Sep 21 '22 13:09

Rebse