SonarCloud Azure DevOps Integration: Project not found. Please check the 'sonar.projectKey' and

Hi,

I’m using SonarCloud with the Azure DevOps Pipeline integration for Pull Request annotations.

A few days ago the Gradle build task started failing with the following error message:

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

There was already a post about this specific message: [SOLVED]Project not found for a new project

There it was a permission issue. Sadly it doesn’t say what and where the issue was. And the specific steps that were done to solve it.

sonar.organization, sonar.projectKey and sonar.projectName are specified in the step Prepare Sonar Configuration.

Thanks for your help.

Hi,

Welcome to the community!

My first thought is that this is a permissions issue too. We saw a case like this recently where the user who owned the token being used for analysis had left the organization. Can you take a look at whether the token in use for this project is still valid?

 
HTH,
Ann

Thank you :slight_smile:

Indeed, the user that was used for the analysis left the organisation. But we deleted and recreated the service connection with an admin user. Verification was also successful:

Also the same user was used for the pull request decoration.

Is it sufficient for the SonarCloud admin who created the token to have the permission set to Basic in Azure DevOps?

Hi,

I’m confused. The user who’s SonarCloud token you’re using for analysis needs to have Browse And Execute Analysis permissions on the project.

I’m not sure what Basic in Azure DevOps is or has to do with it. I guess that token will need the permissions shown in the docs.

 
HTH,
Ann

Hi,

There are two tokens that needed to be exchanged, right:

  1. The SonarCloud Token for Azure DevOps service connection. We did that for the new admin user and as shown in the last post this seems to be working fine.

  2. We added Azure DevOps PAT with Code Read & Write permissions (I think that is what you mean by Browse and Execute) to the Pull Request configuration page of the project.

The documentation states:

Entering the PAT at the organization vs the project level in SonarCloud can lead to differing behavior. We recommend that you follow the tutorial to create a bound organization and make sure that the PAT is entered only at the organization level, not at the project level. The project-level field should be left blank.

Is that something that can lead to this error? I haven’t found a way to change the configuration on the organization level.

The user in step 1 doesn’t need special permissions, right?

Thank you!

Hi,

That’s not what I meant. The user who creates the analysis token in SonarCloud needs to have those permissions on the project in SonarCloud.

Are you still seeing the error you posted in the OP in this thread? You said you swapped out the token generated in/by SonarCloud, right?

 
Ann

Hi Ann,

now it is working!

In the administration panel of the organization we had to give the user execute rights and also on the organizational level the connection to Azure DevOps was not set properly.

So to do it only on the project level was not sufficient.

Thank you very much for your help!

1 Like