Reports not getting uploaded on SonarCloud after Analysis, Throws Project not found

I’m trying to setup SonarCloud on my Azure Pipelines. I have added sonar-project.properties file in the root of my repository which contains the below parameters:

sonar.projectKey=xxxx_xxxxxxxxx
sonar.organization=xxxxx
sonar.projectName=xxxxxxxxx
sonar.projectVersion=1.0
sonar.sources=.
sonar.sourceEncoding=UTF-8

I have added a service connection as well after generating a token from SonarCloud, I’m added as member in the organization.

While running the code analysis, it analyses the code, completes the analysis and then fails with an error below:

##[error]ERROR: Error during SonarScanner execution

ERROR: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator

ERROR:

ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

ERROR: Error during SonarScanner execution

ERROR: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator

ERROR:

ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

Can someone please help me with how we can fix this ?
ErrorRunCodeAnalysis.txt (109.1 KB)

Hi,

Welcome to the community!

Does the project already exist on SonarCloud?

 
Ann

Hi Ann,

Thank you.
Yes, the project exists in SonarCloud. I have followed all the steps mentioned and copied parameters from sonarcloud console while configuring analysis on this project.

Thanks,
Parth

Hi Parth,

The error message lists a couple possible failure points. Paraphrasing:

If you’re sure the first two are spelled correctly (no weird invisible characters anywhere in there…?) then I would look at the analysis token. Is it present? Issued by a user with permissions to analyze the project?

 
HTH,
Ann

Sure Ann,
Couple of questions while I look at the paraphrasing.

  • Does SONAR_TOKEN(analysis token, assuming they are same) need to be a part of the sonar-project.properties file. I have used this token only to create the Service Connection as mentioned in the setup steps.

  • I added SONAR_TOKEN or analysis token as a member of the organization and not the admin, Can this be an issue ? Do we need to create token as an admin ?

Thanks,
Parth

Hi Parth,

I guess this is Azure? I’ll be honest & say I’m not versed in it. The error message mentions the token value being in the environment, so if you’ve done what’s necessary to put it there, then I would think that was enough.

IIRC the token owner needs both Browse and Analyze on the project in question. Can you double-check to make sure you explicitly have both permissions? (Permissions are not cumulative. E.G. If you have Admin on a project but now Browse, you won’t actually be able to see it.)

 
Ann

Resolved this, The problem was with Permissions.
The token creator should have admin permissions to run analysis on Azure Pipelines

1 Like