Main Branch | Sonarqube 8.5

Hi @all,
@OlivierK, as suggested in this Ticket “How to change the main branch in SonarQube?”, here is the new ticket.

I have a question/problem about the Main Branch in the Sonarqube 8.5.

We are currently in the process of updating our Sonarqube (developer Edition) from version 7.9.1 to 8.5.

But before we update our live instance, I would like to test the new features on the test instance.

So, our test instance (developer edition) is now on version 8.5 and I have a question about the process of creating a new project.

Analyzing a new project (first develop) in Sonarqube 7.9.1 means analyzing with the missing parameter “sonar.branch.name”.
The main branch, marked as “master”, has been created but could be renamed to “develop”

On the Sonarqube 8.5 I see two branches -> develop and master. Master branch was created automatically without analysis.

No matter what I do on Sonarqube 8.5, my develop branch is always created parallel to the “master” branch (main branch).

In develop is the result of the analysis and the master is empty, but with the error message “master Branch has not been analyzed yet and you have multiple branches already. It looks like it is not your Main Branch, check your configuration.”

If I want to rename the master branch, like in Sonarqube 7.9.1, it tells me develop already exists.

What is the procedure to create a new project in Sonarqube 8.5 and the develop branch should be my main branch???

thanks
Mark

I don´t use the parameter “sonar.branch.name”, see the following picture.

Sonar plugin in Jenkins -> sonar-scanner-4.5
scanner

The result in sonarqube 8.5 looks like this. The develop branch is created parallel to the master.



Do you have another idea or where is the mistake? I have done so many projects this way in SQ 7.9 without any problems.

thanks,
Mark

Hello @markluebbehuesen,

We hope to make the experience completely fluid soon but indeed with autodiscovery of branches in pipelines you can end up in the situation you describe.
There are solution, the proactive and the reactive.
Proactive:

  • Provision (create) the project before first analysis
  • A default main branch is created, called master
  • Rename that branch as develop
  • Run your pipelines

Reactive (after first analysis, ike in your screenshot)

  • Rename develop into foo (simply to allow the main branch to be renamed develop)
  • Rename master into develop
  • Reanalyze your project to re-set the code on the currently empty develop branch
  • When there will be some code on master the master branch will appear as a “secondary” branch (you should then mark is a branch to retain permanently, not to be purged any time)

… and tada !!!

Hopefully we’ll improve the workflow soon :grimacing:

Olivier

2 Likes