Error when trying to run sonarscanner for my .netcore project

Hi I am exploring sonarqube few days ago. Trying to run the scanner for my .netcore project through CLI and got the error as below.

dotnet D:\SonarScanner.MSBuild.dll begin /k:“testgit1” /d:sonar.host.url=“http://localhost:9000” /d:sonar.login=""
SonarScanner for MSBuild 5.0.4
Using the .NET Core version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories…
10:47:05.063 Updating build integration targets…
10:47:05.173 The token you provided doesn’t have sufficient rights to check license.
10:47:05.182 Pre-processing failed. Exit code: 1

Btw, I follow the documentation in the link as below:
https://docs.sonarqube.org/latest/setup/get-started-2-minutes/

Hi @yapeutat,

Welcome to SonarSource community!

To use SonarScanner for .NET (formerly known as SonarScanner for MSBuild), you have the first right step, but you forgot to pass in your login token, hence the 10:47:05.173 The token you provided doesn’t have sufficient rights to check license. probably.

For the /d:sonar.login property, you need to pass your login token or your login name with the password. In other words, there are 2 ways to pick from:

  1. Login, click on your user icon in the top right-hand corner, click on My Account, click on Security and enter a token name, this will generate a login token, this value is what you put in for /d:sonar.login="2e9f236e256aa0251ed82ae596a871e296e99351":


    For more information, see Generating and Using Tokens.

  2. Use your usual login and password and make sure to pass these analysis parameters to the BEGIN step:
    ... /d:sonar.login="admin" /d:sonar.password="whateverpassword"

Joe

Hi @Joe,

Thanks for your reply.
Actually I did pass in the token, somehow when I post it here, the token is somehow not shown.
I noticed to scan .netcore project using global tool is working fine actualy, but with SonarScanner.MSBuild.dll it’s simply show that error: The token you provided doesn’t have sufficient rights to check license.

@yapeutat: Can you curl and hit this SonarQube web API endpoint and see what the response is?

curl http://localhost:9000/api/editions/is_valid_license

Also, can you take a screenshot of the Administration > Configuration > License Manager screen? Or just send me a private message if it’s better (click on my avatar/icon and click on “Message”).

After I curl that api endpoint, no response is given.

And I can’t seem to find license manager in Administration > Configuration > License Manager

It’s in the drop-down after clicking Configuration, you are on the General Settings screen.

image

Btw I tried again just now, I notice usual login and password actually works like you mentioned as below:
... /d:sonar.login="admin" /d:sonar.password="whateverpassword"

Using the token, somehow always the error: The token you provided doesn’t have sufficient rights to check license

I wanted to follow up on this, as I’m experiencing an identical issue.
I’m running Sonar Server via Docker (Community Image), and authenticating with a freshly-created token as an Administrator using the .NET 5.0 scanner simply doesn’t work.

Likewise, I see no licensing menu option in the administration view.

Further, I’m actually unable to use the solution provided by yapeutat. Entering in the login and password still results in the same message.

Is this a bug with this specific combination of Sonar Server version and the .NET 5.0/.NET Core scanners? Should we be creating a Github Issue?

@yapeutat: very strange, but I’m glad it’s working for you now. Have you tried to revoke and create a new token and try it again?

Also, based on the screenshot from earlier, are you the admin of your SonarQube? Are there other users/admins who can see License Manager menu? What edition of SonarQube are you using (Community, Developer, Enterprise, etc.)?

Hi @Ryanman,

Welcome to SonarSource community! :wave:

Same question I asked yapeutat, are you the admin of your SonarQube? Are there other users/admins who can see License Manager menu? What edition of SonarQube are you using (Community, Developer, Enterprise, etc.)?

If you haven’t already, please review our SonarQube DockerHub page carefully and check your setup.

Hi Joe, yes tried to create a new token and retry and it’s not working either.

FYI, I am the admin of my sonarqube.
I am using Sonarqube Community Edition * Version 8.6 (build 39681)

Just found out the issue.

In scanner SonarQube.Analysis.xml,
http://sonarqubserver:9000
admin
password

If the SonarQube.Analysis.xml is set with the credential as above, then the scanner will only work when username + password provided.

If the SonarQube.Analysis.xml is set using token in the login attribute instead of username + password, then the scanner will work when token is provided.

Thanks for your help anyway!

3 Likes

@yapeutat: Thank you very much for explaining your solution! That is definitely something we should improve in the logs by being more clear of the possible error.

@Joe and others who may find this thread:

  • Yes, I was admin of the SonarQube - the docker images provide default administrator credentials when they’re freshly spun up.
  • I was using the latest “Community Edtion” image
  • Upon killing that container and using just the “Latest” tagged image, the issue was resolved and I was able to perform scans. The problem here of course is that I don’t have a Sonar license.

There’s a gap in my understanding about what’s included or different in the community version or there’s an issue with that image that needs to be resolved, perhaps. I will test Yapeutat’s solution in the community image, but I think we may have sidestepped the issue with the licensing screen?

I can do any additional testing that would be helpful.

2 Likes

Just to add I’m also running into this issue. I’ve been unable to fix using the workaround @yapeutat suggested. I’ve added parameters for username/password to my dotnet sonarscanner begin command and still receive the same error relating to not having sufficient rights to check the license.

I’m running the sonarqube:8.6-community image.

Try restart your machine

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