SONAR_TOKEN does not work in sonarscanner for MSBUILD?

I’m using

  • SonarQube Enterprise Edition 9.9 (65466) and
  • SonarScanner for MSBuild 5.13.1

SONAR_TOKEN does not seem to work in sonarscanner for MSBUILD, even though it says it should

Problem statement

I’m trying to perform a Sonar scan of a dotnet core project against a SonarQube server that needs authentication. According to the documentation here SonarScanner for .NET I can either provide the token using the sonar.token property or create the SONAR_TOKEN environment variable and set the token as its value.

I have tried both ways. Using sonar.token works fine. Setting the environment variable SONAR_TOKEN seems to have no effekt at all - the build fails due to authenication issues.

Commands being run*

dotnet new tool-manifest
dotnet tool install dotnet-sonarscanner
dotnet sonarscanner begin ........

I have tried the same command successfully when the authentication on the server has been turned off. And when authenication is turned on, it works if I add -d:sonar.token=$SONAR_TOKEN

Should SONAR_TOKEN work or is the documentation wrong? Or did I do something wrong?


Welcome to the community!

Since you’re using SonarQube 9.9, you’ll want to use the 9.9 docs as your reference. sonar.token hadn’t been introduced yet in 9.9, so you’ll need to pass your token value as the argument to sonar.login instead.


A post was merged into an existing topic: onarQube Warning - The property ‘sonar.login’ is deprecated and will be removed in the future