Search code examples
javamavenjenkinssonarqubesonar-runner

Wrong projectKey with Jenkins Build on Sonar Analysis


I'm having some trouble and I'm trying to fix my Jenkins builds.

I use it to build the same project but different branches. So, to separate the result for the Sonar analysis.

In the Build tab from my project, the options I set are : clean install -DtestFailureIgnore sonar:sonar -Dsonar.projectKey=MY_PROJECT_KEY

For some builds, it just works perfectly fine, and for some others, my project key in Sonar become groupId:artifactId using the pom.xml data, and it makes Sonar mixing some of the branches.

Does anyone know how to help about that problem?

Sonar version: 5.4

Jenkins version: 1.651.1


Solution

  • This is expected behaviour. When analysing Maven projects with the SonarQube Scanner for Maven, sonar.projectKey is automatically set to <groupId>:<artifactId>.

    To analyse different branches of the same project: do not override sonar.projectKey , simply use the sonar.branch parameter.

    Full details in the SonarQube Analysis Parameters documentation.