SonarCloudAnalyze step in DevOps suddenly failing

Hey. We have an issue in our DevOps project. We have set up SonarCloud CLI analysis, but it suddenly broke for us on 07/06/2024. We have done no code changes and this affects multiple branches in our project. Rerunning old code that succeeded now fails. The error is below. I have tried revoking the project key and added a new one, but we still encounter the same issue.
What could be the issue?

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 to check the permissions of the user the token belongs to

Hey there.

Is your organization still bound with a valid token? You can check the global ** Administration> Organization settings > Azure DevOps connectivity management?

If so, it would help to see a wider range of logs (specifically with verbose logging, sonar.verbose=true) to understand precisely which API call failed.

I built again with verbose enabled. The organisation contains multiple projects and the other projects seem to be working as intended. It’s just this project that has the issue. I do see that the SonarCloudAnalyze task is a deprecated version. Would it help if I upgraded it to the latest one?

09:59:10.470 INFO: EXECUTION FAILURE
09:59:10.470 INFO: ------------------------------------------------------------------------
09:59:10.470 INFO: Total time: 1:49.701s
09:59:10.750 INFO: Final Memory: 180M/607M
09:59:10.750 INFO: ------------------------------------------------------------------------
##[error]09:59:10.750 ERROR: Error during SonarScanner execution
09:59:10.750 ERROR: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator to check the permissions of the user the token belongs to
09:59:10.750 ERROR: 
09:59:10.750 ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
09:59:10.750 ERROR: Error during SonarScanner execution
09:59:10.750 ERROR: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator to check the permissions of the user the token belongs to
09:59:10.750 ERROR: 
09:59:10.750 ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
09:59:10.759 DEBUG: Cleanup org.eclipse.jgit.util.FS$FileStoreAttributes$$Lambda$282/(redacted) during JVM shutdown
##[warning]LIB_ResourceFile does not exist
##[warning]Resource file haven't been set, can't find loc string for key: LIB_ProcessExitCode
##[warning]Error while executing SonarCloud:Analyze task: LIB_ProcessExitCode /home/vsts/work/_tasks/SonarCloudAnalyze_(redacted)/1.45.1/sonar-scanner/bin/sonar-scanner 2
##[error]LIB_ProcessExitCode /home/vsts/work/_tasks/SonarCloudAnalyze_(redacted)/1.45.1/sonar-scanner/bin/sonar-scanner 2
Finishing: SonarCloudAnalyze

I’m really curious about what’s happening right before this.

I don’t expect so, but you can try. If you’re still facing an issue, I’d suggest sharing your Azure Devops Pipeline YML here.

I’ll include some of the log from above EXECUTION FAILURE

09:59:09.638 INFO: Analysis report generated in /home/vsts/work/1/s/.scannerwork/scanner-report
09:59:09.638 DEBUG: Upload report
09:59:09.642 DEBUG: --> POST https://sonarcloud.io/api/ce/submit?(redacted org + projectKey query strings)&characteristic=branchType%3DSHORT (702576-byte body)
09:59:09.730 DEBUG: <-- 404 https://sonarcloud.io/api/ce/submit?(redacted org + projectKey query strings)&characteristic=branchType%3DSHORT (88ms, unknown-length body)
09:59:09.737 DEBUG: Shutting down the worker
09:59:09.743 INFO: Rule                                          | Time (ms) | Relative
09:59:09.743 INFO: :---------------------------------------------|----------:|--------:
09:59:09.743 INFO: deprecation                                   | 14769.809 |    35.8%
09:59:09.743 INFO: ucfg                                          |  6925.977 |    16.8%
09:59:09.743 INFO: no-redundant-assignments                      |  2734.391 |     6.6%
09:59:09.743 INFO: no-dead-store                                 |  2158.939 |     5.2%
09:59:09.743 INFO: aws-restricted-ip-admin-access                |  1779.112 |     4.3%
09:59:09.743 INFO: no-misused-promises                           |  1557.558 |     3.8%
09:59:09.743 INFO: no-duplicates                                 |  1114.990 |     2.7%
09:59:09.743 INFO: no-unstable-nested-components                 |   716.165 |     1.7%
09:59:09.743 INFO: no-direct-mutation-state                      |   666.609 |     1.6%
09:59:09.743 INFO: no-commented-code                             |   340.814 |     0.8%
09:59:09.743 INFO: no-array-index-key                            |   327.127 |     0.8%
09:59:09.743 INFO: hook-use-state                                |   257.497 |     0.6%
09:59:09.896 INFO: :----|----------:|--------:
09:59:10.467 DEBUG: Cleanup org.eclipse.jgit.util.FS$FileStoreAttributes$$Lambda$282(redacted) during JVM shutdown
09:59:10.469 INFO: ------------------------------------------------------------------------
09:59:10.470 INFO: EXECUTION FAILURE

I updated the tasks to version 2. Doesn’t seem like it affected anything except for getting rid of the deprecated warnings.

Are you sure you do not have an issue with your SonarCloud token or are suddenly missing permissions (such as execute analysis) for the SonarCloud user with the corresponding token?

I’ll investigate some more. I think you are correct, but I have already checked the token issues.Maybe I missed something. I’ll write here again if I find the answer

Seems like our organisation admin got rid of some permissions on the user with the API token. Everything works fine after they reverted it :slight_smile:

1 Like