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.
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.
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’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
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.
@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.
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
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 ?