Sonar Cloud Properties

Hello community,

I’m trying to use Sonar Cloud with a monorepo configuration. With monorepo, I believe I can have sonar-project.properties for each services in monorepo. I’m trying to use it so that Sonar Cloud doesn’t need to scan everything inside the directory, because there are several files that are generated and it’s pretty long to be included in LOC count.

When I tried to use several properties like sonar.sources and sonar.exclusions, in Sonar Cloud Dashboard, I can see that this files are being scanned and still counted in LOC. I also found the similar setting in Administration > Analysis Scope but all of the default value is <no value>. Does it mean that it failed to read sonar-project.properties or does it ignore it? What if I insert through this setting, will it overried the one in sonar-project.properties or the other way round?

Thanks in advance!

Hey there.

Yes, you can have seperate sonar-project.properties file for each service. And you are going to need to have multiple SonarCloud projects that are scoped specifically to that part of the repo. Is that the case?

Which CI are you using? We have some good examples in the docs, like for GitHub Actions (notice how the projectBaseDir is set for each scan – this how the scanner knows where to look for different sonar-project.properties files).

No matter what, you won’t see these values reflected in the UI (stuff that is set in sonar-project.properties file don’t show up in the project administration space).

You can read about settings hierarchy here.

Hi Colin,

Thanks for your answer. Yes, I’m using Github Actions to run the scan. I’m also kinda confused with where does it start to read the path in sonar.exclusions properties. I want to exclude all files inside ignored but I can’t use sonar.exclusions=./ignored/*, meanwhile if I use **/ignored/*, it works.

I also want to know in Github Actions, can we only make 1 Github Action so that it is parameterized for each similar folder in a monorepo, or do we need to make each one of them for each folders?

Thanks in advance!

From the base directory – and using glob patterns (which won’t take ./ into account. I expect ignored/** will also work).

To be honest, I don’t know GitHub Actions this well. :confused: But I’m sure our GitHub action is compatible with whatever mechanisms has to parameterize pipelines.

1 Like

Okay thanks, I will try it out more about it. Thanks for your help Colin