ERROR: You're not authorized to run analysis. Please contact the project administrator

Hi,

I am trying to run the code analysis using sonar cloud.
when i run the analysis i’m stuck at the error saying “ERROR: You’re not authorized to run analysis. Please contact the project administrator.” ,
Seems like the analysis report is generated and when it’s trying to upload the analysis report to sonar cloud the execution is getting failed with the error.
Please suggest how to overcome this error and run the analysis successfully.

Command used to run the analysis : sonar-scanner -X -Dsonar.host.url=https://sonarcloud.io/ -Dsonar.projectKey=ajaykumar0794_Sonar-Scanning-Examples

I tried multiple options as below for this error and not able to resolve.

I’ve tried added sonar.properties file in my repository with the below details, still getting the same error.
-Dsonar.organizationKey=XXXXX
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.projectKey=XXXX
-Dsonar.login=XXXXXX(Encrypted Key)

I’ve tried giving all the permissions to run the analysis in sonar cloud(Organisation-Adminstration-Project Management,Permissions) and in my Azure repository too. Still no luck.

Hi,

First make sure the user who created the token passed to sonar.login has the “Execute Analysis” permission (in the administration->permissions menu of your project).

The properties in sonar.properties shouldn’t start with -D. So instead -Dsonar.host.url=https://sonarcloud.io you should have sonar.host.url=https://sonarcloud.io.
Also sonar.organizationKey should be replace by sonar.organization.

Let me know if this helps!

Hi Benoit,

I tried running the sonar analysis by updating the sonar properties file as you suggested and checked the permissions too, But still getting the same error.

I missed that in your first message but your file should be named sonar-project.properties and not sonar.properties.

Hi Benoit,

I’ve tried running the analysis after editing the properties file as you suggested, the execution is success and able to see the analysis on the cloud too.

Thanks a lot for the quick help and support.

Command Used to run the analysis:
sonar-scanner -X -Dsonar.host.url=https://sonarcloud.io/ -Dsonar.projectKey=Sonar-ABAP-Test-New

Hi @benoit,

I’m facing the same error while running the sonar scan through Jenkins for a maven project.

I’ve tried giving the required access in the project level, replaced - Dsonar.host to Dsonar.host too.

I’m running the sonar-project.properties through ‘Execute sonarqube scanner’ module in Jenkins.
Properties mentioned so far:

Sonar.projectKey=
Sonar.projectVersion=
Sonar.java.binaries=
Sonar.sources=
Sonar.exclusions=

Please let me know what went wrong in this.

Hi @Sudhir @t.ajaykumar,

Sorry for the late response.
I think you are missing the sonar.organization property.
I see that this parameter is missing from the documentation, I will add it.

Let me know if that fixed your error.

Yes, even I have figured out the same and resolved the issue now.

Anyways thank you for the response. :slight_smile:

@benoit I get the same error but my problem was different I was sending a project key that was already taken, I have changed that and it worked. The problem here is sonarcloud is not giving any clue about the problem instead it directs you to a wrong path by saying it is an authorization issue.

1 Like

I completely agree with the commentator above. My problem was that I changed the paths to the sources and tests. And wrote the authorization problem, although this is not so

Hi @benoit,

I’m also facing the same issue:
file for sonar properties: sonar-project.properties

also have mentioned the sonar.organization in the sonar-project.properties file as shown below:

sonar.projectKey=xxxx
sonar.projectName=xxxx
sonar.projectVersion=xxxx
sonar.organization=xxxx

the command used for execution:
dotnet tool install --global dotnet-sonarscanner --version 5.2.0

dotnet sonarscanner begin /k:xxxx /d:sonar.host.url=https://sonarqube.xxxx.com /d:sonar.login=${SONAR_USER} /d:sonar.password=${SONAR_PW} /d:project.settings=C:\xxxx\sonar-project.properties

dotnet sonarscanner end /d:sonar.login=${SONAR_USER} /d:sonar.password=${SONAR_PW}

ERROR: Error during SonarScanner execution

(https://gitlab.com//-/jobs/1225392233#L5064)ERROR: You’re not authorized to run analysis. Please contact the project administrator.

thanks in advance

Hi ALL,
I am having the same issue here :

ERROR: Error during SonarScanner execution
ERROR: You're not authorized to run analysis. Please contact the project administrator.
ERROR: 
The SonarScanner did not complete successfully

@t.ajaykumar what properties file you are talking about ?

why does one project fails and other one succeeds with this configuration?

1 Like

We solved it by using a permission template which can do anything and added to Administrator Group