Search code examples
javamavensonarqubesonarcloud

Error while setting up SonarCloud for a multimodule Maven project


Project is hosted on:

the used command locally : mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar secret was added to github or to env variables, and properties where added to core/pom.xml Different solutions where tested:

  • First Test As suggested by the Sonarcloud configuration page the below properties where added but we got an error

    <sonar.projectKey>opencellsoft_core</sonar.projectKey> <sonar.organization>opencellsoft</sonar.organization> <sonar.host.url>https://sonarcloud.io</sonar.host.url>

Error:

Project 'opencellsoft_core' can't have 2 modules with the following key: opencellsoft_core
  • Second attempt transform the projectkey to

    <sonar.projectKey>opencellsoft_core-${project.groupId}:${project.artifactId}</sonar.projectKey>

Error:

You're not authorized to run analysis. Please contact the project administrator.
  • 3rd Attempt Add modulekey properties

<sonar.projectKey>opencellsoft_core</sonar.projectKey> <sonar.moduleKey>${project.groupId}:${project.artifactId}</sonar.moduleKey>

Error:

You're not authorized to run analysis. Please contact the project administrator.

Do you have any idea how to resolve this issue ?

Thanks


Solution

  • The third solution was correct but need to add the secret token in Repository secrets instead of environment secrets in Github. More information can be found here https://community.sonarsource.com/t/error-while-setting-up-sonarcloud-for-a-multimodule-maven-project/39880/2