Multi projectkey in single sonar-project.properties file

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension) : Enterprise
  • how is SonarQube deployed: zip, Docker, Helm : On premises
  • what are you trying to achieve: We multi language (C++, C# ,TS) projects in single repository and we would like scan each projects separately and send scan result to different SonarQube projects. But we would like use single properties file at root.

For example:
app
├── path1
│ ├── src
│ └── test
├── path2
│ ├── src
│ └── test
mod
├── path1
│ ├── src
│ └── test
├── path2
│ ├── src
│ └── test
└── sonar-project.properties

sonar-project.properties:
#meta data…
sonar.host.url=<SONAR_HOST_URL>
sonar.verbose=true
sonar.modules=mod,app #Example of modules
#app
app.sonar.projectBaseDir=./path1
app.sonar.projectKey=<SONAR_KEY>
#mod
mod.sonar.projectBaseDir=./path2
mod.sonar.projectKey=<SONAR_KEY>

  • what have you tried so far to achieve this Our Ask:
  1. Can use multiple project key in single sonar-project.propertie files
  2. Does sonarqube modules approach best fit our use case?
  3. Any better suggestion do you have details our use case

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

Hi,

Welcome to the community!

What you’re after is monorepo analysis. You can do it, but you’ll need to set properties per SonarQube project. You can do that in (multiple!) properties files or on the analysis command line.

The module configuration you’ve outlined won’t do what you think. It will analyze all your modules as one, combined project.

Having said (written) that, having one properties file for the common values might not be a bad idea:

And then pass the other values, such as sonar.sources on the command line.

 
HTH,
Ann

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.