Can't have 2 modules with the following key

Hi Team,
I’m trying to decorate Sonarcloud in bitbucket for every pull request and commit. The project which I am using is a java maven based.

I’ve created the bitbucket-pipelines.yml file as per the documentation. After raising a pull request, the Pipeline is running fine but it’s ending with a error:

Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project ** : project ‘’ can’t have 2 modules with the following key : *** Help 1

Project structure:

-ABC
   Ert
      - Pom.xml
      -.gitignore
   Dfg
   Ghj
   Tiy
   Pom.xml
   Settings.xml

-.gitignore

-Bitbucket-pipelines.yml 

Could you please help me with this error?

Thank you,

Does this happen only for pull requests, or for analyzing master too?

I’m wondering if the problem might be that the project key as inferred from pom.xml might already exist on SonarCloud, owned by another user. (In that case all your analyses of the project will fail with the same error, including master, not only pull requests.) You can override the project key determined from pom.xml by setting -Dsonar.projectKey=... explicitly when running mvn sonar:sonar.

Can you please answer to my question above, and clarify if this helps?

This happened for me since in .m2/settings.xml i already configured a different project key and i was providing a different key at runtime scanner.

1 Like