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: