20

I have a Mono repo in which all my Spring boot based micro service reside.

I know how to configure a SonarQube analysis for poly repo but wondering how sonarqube analysis can be done on a monorepo and how Soanarqube can identify different projects inside the mono repo.

Is there a different type of configuration I have to do with Sonarqube ?

5
  • What is a "Mono repo" ?
    – janos
    Commented Oct 5, 2019 at 18:34
  • See here for example: en.wikipedia.org/wiki/Monorepo
    – donmartin
    Commented Dec 20, 2019 at 13:12
  • 2
    @Spencer Bharath Did you ever figure this out?
    – Bob
    Commented Jan 23, 2020 at 7:06
  • 3
    On 1 on july they finally added support for GitHub (and earlier for Azure DevOps). I haven't it yet, will be setting it up now. but in case anybody else is interested the documentation is here sonarcloud.io/documentation/analysis/setup-monorepo
    – Olga
    Commented Aug 12, 2020 at 15:34
  • the OP is for SonarQube as well. I am wondering how it is for the on-prem version Commented Jan 23, 2023 at 2:23

2 Answers 2

1

As said in the comments, monorepo support is available for GitHub and Azure DevOps Services. If your repository is hosted by one of these services, you can import a monorepo with this procedure:

  • Go to the + (plus) menu on the top right of the SonarCloud interface and select Analyze new project.
  • This will take you to the Analyze projects page
  • Now click Setup a monorepo (it is a small text link on the lower right of the page). You will now be on the Import monorepo page.
  • Select the organization and then select the monorepo repository that you want to import.
  • For each project contained in your monorepo, add a corresponding SonarCloud project by clicking "Add new project". You have to choose a unique project key for each SonarCloud project. As mentioned above, these are the keys that you will use when configuring your CI service (see below) to bind each monorepo project to its corresponding SonarCloud project.

Full details in the sonar blog post: Mono-repository support for GitHub and Azure DevOps Services available now!

Note that:

2
  • If I understand the documentation and behavior of the Sonarcloud UI correctly, doing this requires setting up a PAT in Azure Devops which is tied to an AD user. For various reasons, tying our CI pipeline to a specific user is not best practice. Is there any alternative method for setting up the monorepo in Sonarcloud that does not require a PAT?
    – Fred
    Commented Jun 14, 2022 at 18:47
  • @Fred, I believe setting up Sonarcloud generally requires a PAT. Rather than tying the PAT to a real person who may eventually move on from the company, I've created a "service account" its only purpose is to be the account referenced when we don't want to tie things to a real user. It is by no means a perfect solution, as the next question is, "how do people access this account when a new PAT needs to be generated for something else?" but it's the best solution I've seen so far for handling long-lived things that we don't want to break when someone leaves the company. Commented Nov 28, 2022 at 15:41
1

As of writing SonarQube 9.8 does not mention the word monorepos in their documentation search. So you'd have to create separate projects manually if you are using an on-prem version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.