SonarCloud Can't find Project using project key

Is anyone else experiencing issues with sonar cloud no longer able to find the using the project key when performing an analysis on a PR in Azure DevOps.

We have configured SonarCloud to perform a code analysis on every PR we do and we have linked the repos to 33 projects in SonarCloud. It’s been working fine for the past few months, but now it’s failing with the following errors message:

##[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:

We have renewing the PAT just in case it was an issue with the token expiring.

Anyone else experiencing this?

Any help greatly appreciated!

Thanks

Hey there.

It’s a bit difficult to see from the error message exactly where the issue is cropping up. Can you share a bit more of what’s happening in the logs before you receive the message?

Here is the full log: Thanks for your help

NFO: Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu

INFO: User cache: /home/AzDevOps/.sonar/cache

INFO: Load/download plugins

INFO: Load plugins index

INFO: Load plugins index (done) | time=194ms

INFO: Load/download plugins (done) | time=2669ms

INFO: Loaded core extensions: developer-scanner

INFO: Found an active CI vendor: 'Azure DevOps'

INFO: Load project settings for component key: 'Staffcircle_Platform-UI-Webpack4-vuecli'

INFO: Load project settings for component key: 'Staffcircle_Platform-UI-Webpack4-vuecli' (done) | time=145ms

INFO: Process project properties

INFO: Execute project builders

INFO: Execute project builders (done) | time=1ms

INFO: Project key: Staffcircle_Platform-UI-Webpack4-vuecli

INFO: Base dir: /agent/_work/1/s

INFO: Working dir: /agent/_work/1/s/.scannerwork

INFO: Load project branches

INFO: Load project branches (done) | time=197ms

INFO: Check ALM binding of project 'Staffcircle_Platform-UI-Webpack4-vuecli'

INFO: Detected project binding: BOUND

INFO: Check ALM binding of project 'Staffcircle_Platform-UI-Webpack4-vuecli' (done) | time=136ms

INFO: Load project pull requests

INFO: Load project pull requests (done) | time=238ms

INFO: Load branch configuration

INFO: ------------------------------------------------------------------------

INFO: EXECUTION FAILURE

INFO: ------------------------------------------------------------------------

INFO: Total time: 9.731s

INFO: Final Memory: 19M/74M

INFO: ------------------------------------------------------------------------

##[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.

##[error]The process '/agent/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.34.0/sonar-scanner/bin/sonar-scanner' failed with exit code 2

Finishing: Run Code Analysis

Thanks!

It looks like SonarCloud faces a 401 issue getting in touch with Azure DevOps when looking up your pull request.

Can you make sure you have configured a valid token at either the project-level Administration > General Settings > Pull Requests ) or at the organiztion-level (Administration > Organization settings > Azure DevOps connectivity management )?

Thanks, sorted now, it was an expired PAT in the end

1 Like

@Colin is there a way to tell from the error messages from SonarCloud that the issue is in fact an expired PAT?

We’re experiencing a similar issue, but have contributed to the following thread about it: ERROR: Failed to prepare write of the sensor cache

1 Like

Hey @AdinErmie

This is something I’ve advocated for in the past, but it has been a while. I’ll ping around on this topic (because I’m a bit tired of copy/pasting the answer!)

1 Like