I have a small OS tool project using a multi-module Maven build.
I added the sonar.properties and now try to run the analysis from Github Actions (also tried locally with same result), but I always get an error during Sonar analysis
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:188.8.131.526:sonar (default-cli) on project upm-client: Project ‘cbromberg_upm-client’ can’t have 2 modules with the following key: cbromberg_upm-client -> [Help 1]
Here’s a link to the run on Github https://github.com/cbromberg/upm-client/pull/2/checks?check_run_id=894100583
I assume it has something to do with the multi-module structure …Any ideas what to do.
The maven build worked before that.
First, because you have a Maven project to scan, you don’t need at all a sonar-project.properties. You should remove it.
Here what I did on my side for your project. I forked it here https://github.com/agigleux/upm-client, then I switched to SonarCloud and declared it (click on the top right on the + icon “Analyze new project”). I selected my organization called “agigleux”, then the project “upm-client”. The tutorial is telling me SonarCloud can’t scan it (because it’s made of 100% of Java), so I have to trigger the scan from my CI or locally. I selected manually to get the details about the “sonar.projectKey” and “sonar.organization”
I cloned the project locally to validate it’s working fine and then I run:
mvn clean verify -DskipTests=true \
-Dsonar.login=replaceme sonar:sonar \
Can you try that on your side to first confirm it’s working outside of GitHub Actions context?
Regarding GitHub Actions configuration, you should have a look at this sample: https://github.com/SonarSource/sonarcloud-github-action-samples/tree/maven
Thanks a lot - the problem was that I had copied the sonar.projectKey into my pom.xml and it seems that this caused the maven sonar analyser to use the same projectKey for every module.
Maybe you should change the getting started guide then, because it suggests to do exactly that:
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.