How to upgrade from regular to mono repo project?

Hello :waving_hand:

Here is my problematic in the context of SonarQube cloud :

I have X regular Github repositories, and on SonarQube side, each of them are configured in order to be incrementally fed with Sonar scanner, I.E. running commande `mvn -f ./pom.xml sonar:sonar …`, whenever our CI run

We’ve decided to merge those X repositories into one of them, to eventually have a mono repo

On SonarQube cloud side, is it possible to change the configuration of the selected host repository in order to turn it into a mono repo one, while keeping the feeding with scanner runs from our CI ?

Is there any documentation that could explain that ?

I’m kinda lost as the entry dedicated to this subject on SonarQube Cloud documentation seems to “only” explain how to configure it from scratch, not how to upgrade one

Thanks in advance for your help on that matter :folded_hands:

Best regards

Benoit

Hi @Mumeii,

Thanks for reaching out.

What are the primary results you want out of a monorepo construction in SonarQube?

To adjust to the new structure, you don’t need to explicitly convert them to a monorepo construction inside Sonarqube. Here’s some steps you can follow:

  1. In the new monorepo CI pipeline, add a Maven scan job per component, pointing projectBaseDir at the right subdirectory
  2. Each job uses the same sonar.projectKey as the original project
  3. Analysis keeps flowing to the existing SonarCloud projects keeping history intact
  4. No SonarCloud reconfiguration required

With this approach history of the projects is kept intact.

However, one benefit of a monorepo construction in SonarQube is the ability to post the PR status check to Github using the unique context string [Project Name] SonarCloud Code Analysis rather than the generic SonarCloud Code Analysis. Without a monorepo construction GitHub treats that as a single status, each component’s analysis overwrites the previous one. Only the last scanner job to finish shows up on the PR.

If you need that functionality, you would need to go through this process:

  1. Go through the monorepo wizard pointing at the new monorepo repo
  2. The one existing SonarCloud project already bound to that repo (if any) gets converted automatically, it keeps its history
  3. All other components must be created as new projects and they start fresh with no history
  4. Update CI to use the new project keys per component

This gets the monorepo UI grouping and proper per-component PR quality gates, but sacrifices history on all but one project.

Does that make sense?

Hope that helps.

Stevan

Hi @stevan.vanderwerf

Thanks for your reply, and sorry for the long delay of mine !

Your explanation is making sense, plus I had the opportunity to test, and indeed the way Sonar behave after the merging is ok for us.

We don’t have fancy per module entries placed on our PRs, but a single one instead, and that’s fine for us :+1:

Best regards

Benoit