I have a monorepo with 3 different apps inside. these apps are under ./apps
I followed the documentation (
Monorepo Support | SonarCloud Docs) but is still not clear for me how this works.
So if I understood correctly, we can setup a specific quality gate for each app, and that I managed to create. I have now 3 project keys one for each app.
Following the github actions tutorial it have to create a
./github/workflows/build.yml file and thats fine, but then it ask me to create one
sonar-project.properties on the root folder
The problem is that I have 3 different apps, and only one
sonar-project.properties file, so how can I match the specific app with the specific project key?
Thank you in advance!
You’ll need to have a different
sonar-project.properties file for each app, and then set the base directory for each separate scan. Take a look at the example here:
Welcome to our community!
You should run the GitHub action from the base directory of each project in the monorepo. And there’s a clever projectBaseDir parameter available for the action! Take a look at the example below:
- uses: actions/checkout@v2
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: SonarCloud Scan
Hi Colin ty for the quick reply!
ok I should setup in the github action file the 3 different
projectBaseDir but how they relate with each separate quality gates? there is no link
SONAR_TOKEN are all the same
sonar-project.properties that you place in the root directory of each app (the base directory you are configuring for the scan, not the whole repo) will contain a sonar-project.properties file each with a different project key.
ok got it. so this means that now if there is a PR to a specific app, only that quality gate is going to run right?
what happens then if a developer also updated some root files? that are not inside
apps/ folder? will sonar still run? no right…
That really depends on how you’ve configured your build – when you change the code in one app, do all of your apps build?
If so – then yes, scans will run for all three projects and a Quality Gate will be reported for each application. However, if no code changed in the other apps, those Quality Gates shouldn’t change.
It depends on how you’ve configured your actions.
There are features of GitHub actions to limit runs to when certain files change.
so if I configure my action with
with: projectBaseDir: apps/app-1/ then if I understood correctly only the contents of this folder will be taken in consideration right? and then inside that folder I have the
sonar-project.properties that then will inform sonar cloud which quality gate to use.
maybe apart from those 3 steps (actions) i need to create a default one without
projectBaseDir and then configure my monorepo again with a root quality gate excluding the
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.