SonarQube using branchname instead of project-key value

I am 8.2 developer edition and using Jenkins to run the SonarScanner for MSBuild 4.9 on a dotnet framework project. However despite passing the project key in as a parameter it is still creating a new project in SonarQube based on the branch name. So for each branch I get a new project.

The code being used is:

        bat "SonarScanner.MSBuild.exe begin /k:\"${sonarprojectkey}\" "
        bat "\"${tool 'msbuildhome'}\\MSBuild.exe\" \"${env.WORKSPACE}\" /t:Rebuild"
        bat "SonarScanner.MSBuild.exe end"

Is there somewhere else I should be passing the project key?

I have enabled verbose logging and found that the .sonarqube\out\.sonar\mod2 folder.
When I navigate to this folder I can see in the file there are two entries for sonar.projectKey=.

The one at the top is the correct value I pass I the switch parameter but the last one is the branch name.

Is this a bug or I am missing a configuration somewhere?

Apologies, another Jenkins admin had set the ‘Additional Analysis Properties’ to be the job name and didn’t tell anyone. This was easily fixed but it is worth sharing the project key can be overridden in Jenkins.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.