Not able to configure CircleCI for monorepo in SonarCloud

  • ALM used: GitHub

  • CI system used: Circle CI

  • Scanner command used when applicable (private details masked): We are using the Sonarcloud orb

  • Languages of the repository: Typescript

  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting):
    ERROR: Error during SonarQube Scanner execution
    ERROR: You must define the following mandatory properties for ‘Unknown’: sonar.projectKey, sonar.organization

  • Steps to reproduce:

  1. Have a Github monorepo consisting of two packages (RepoA with ProjectA and ProjectB)
  2. In SonarCloud, import the repo as a monorepo creating two projects (org_RepoA_ProjectA and org_RepoA_ProjectB)
  3. Configure the for both files, adding the sonar.projectKey and sonar.organization to both of them
  4. Configure circle.yml, using the orb
  5. Execute the pipeline

Currently, following step by step the documentation, we get the error I wrote above.

Our issue is that right now it seems that when the CircleCI pipeline executes, the orb does not seem to be reading the files inside each project.

Are we missing something? Do we need to add an extra command or something in the circleci yml to let the orb know where to get the file?

We even tried adding the monorepo itself as one of the projects to add a file with the node.modules added to specify the route to each project, and did not work either.

I don’t know if I am explaining myself, but hopefully we can get some help.

It’s the same issue as in here: Monorepo in circleCI failing to find SC config

The difference is our config.yml for CircleCI is on the root of the repo, not inside each project.

Hey there.

Using the latest version of the orb, you can set project_root to change into the directory of each project for each scan.

1 Like

I knew about that, I was just editing my post, the thing is I am not sure if we need to add the “parent” repo as a project as well in Sonarcloud or we just add the sub-projects and that’s it. Like, do I need to add RepoA as a project in SonarCloud and create a file in the root of RepoA?

You only need the sub-projects.