Error during SonarQube Scanner execution - Insufficient privileges

Hello,

I have a project in Sonar cloud. I am trying to scan my code, but when I execute the instruction

SonarScanner.MSBuild.exe end

I get the next error:

ERROR: Error during SonarQube Scanner execution
ERROR: Insufficient privileges
ERROR: The SonarQube Scanner did not complete successfully

The complete command is:

SonarScanner.MSBuild.exe begin /k:“XXXXXXX”
MSBuild.exe /t:Rebuild
SonarScanner.MSBuild.exe end

My code is C#.

what am I doing wrong?

Alejandro,

Two possibilities come to mind:

First: If the settings for who can execute analysis (globally or on the project in question) are not set to “Anyone”, you need to provide credentials in your command. Check out the sonar.login and sonar.password analysis properties and documentation specific to SonarQube Scanner for MSBuild. Some more information about Authorization and permissions are available here.

The second, more of a “gotcha” possibility is that if the project you specified doesn’t already exist on the SonarQube server, the scanner will attempt to create the project with the key supplied.

If the user running the scan doesn’t have permission to create projects (or no login information is specified, see above), I believe it will fail with an insufficient privileges error. If you want to keep tight control on what projects are created, and make sure new ones don’t sprout out of a mistyped argument, I would create the project beforehand and seperate those permisisons from the user you use in your scan.
.
Hope this helps,

Colin

1 Like

Hi @agjj677,

@Colin is right but I would start with some more basic diagnostics. You mention

The complete command is:

and if that’s really the case then you are missing both the organization (/o:<YOUR_ORG>) and the credentials (/d:sonar.login=<TOKEN>).

Cheers,
Amaury

2 Likes

Hi @Ammo,

I change my command for:

SonarScanner.MSBuild.exe begin /k:“XXXX” /d:sonar.organization=“XXXX” /d:sonar.host.url=“https://sonarcloud.io” /d:sonar.login=“XXXX”
MsBuild.exe /t:Rebuild
SonarScanner.MSBuild.exe end /d:sonar.login=“XXXX”

and scan perfect.

thank

1 Like