Hello everyone and happy new year
Must-share information (formatted with Markdown):
- which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
SonarQube Community 10.3, Jenkins SonarQube Scanner
- Issue
I have a monorepo consisting of several packages, each having its own SonarQube project.
repository root
- /packages
-- /package1
--- sonar-project.properties
--- /src
-- /package2
--- sonar-project.properties
--- /src
The Jenkins job (for the whole repository) runs one SonarQube analysis per package in the repository. Each step consists of picking up the sonar-project.properties
file of the corresponding package.
What this Jenkins step does is set the project.settings
property with, here, packages/package1.sonar-project.properties
Now for the content of the properties file, the following does not work
package1/sonar-project.properties
sonar.sources=src
Because the scanner resolves sources from the root of the repository, and not from the directory where project.settings
was found. (Nothing alarming so far)
Now, according to the Analysis parameters documentation, the sources are resolved from sonar.projectBaseDir
, which very logically would correspond to the folder where all the files pertaining to that Sonar project belong.
So I would expect the following to work:
package1/sonar-project.properties
sonar.projectBaseDir=packages/package1
sonar.sources=src
But it doesn’t, the sources are still resolved from the repo root.
ERROR: The folder 'src' does not exist for 'package1' (base directory = /my/workspace/root)
To understand why, I had to stumble upon an old StackOverflow thread which mentions that project.settings
and sonar.projectBaseDir
are incompatible.
Unfortunately it seems to still be the case even though it is not mentioned anymore in the documentation.
The following works for me:
package1/sonar-project.properties
sonar.sources=packages/package1/src
But it limits the practicality and maintainability of the config files, because a lot of properties will have that baseDir path duplicated.
- What I expected
Firstly, this limitation should be explicit in the documentation, can it be updated?
Then, is there a way for this limitation to be fixed or worked around in a future SonarQube version?
Thank you very much!