Sonarcloud Analysis failing with "project not found" in Azure DevOps

When running SonarCloud scans in Azure DevOps, we’re seeing the following logs in the SonarCloudAnalyze@1 job

16:27:11.366 DEBUG: Upload report
16:27:11.864 DEBUG: POST 404 https://sonarcloud.io/api/ce/submit?organization=<REDACTED_ORGANIZATION>&projectKey=<REDACTED KEY>&projectName=<REDACTED_PROJECT_NAME>&characteristic=branch%3Dweaverc%2FOBD-5225&characteristic=branchType%3DSHORT | time=498ms
16:27:11.877 DEBUG: eslint-bridge server will shutdown
16:27:16.879 DEBUG: eslint-bridge server closed
16:27:16.879 INFO: Time spent writing ucfgs 27ms
16:27:17.304 INFO: ------------------------------------------------------------------------
16:27:17.304 INFO: EXECUTION FAILURE
16:27:17.304 INFO: ------------------------------------------------------------------------
16:27:17.308 INFO: Total time: 44.049s
16:27:17.416 INFO: Final Memory: 43M/147M
16:27:17.416 INFO: ------------------------------------------------------------------------
##[error]16:27:17.416 ERROR: Error during SonarScanner execution
Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator
16:27:17.416 ERROR: Error during SonarScanner execution
Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator
Process returned exit code 2
##[error]The SonarScanner did not complete successfully
The SonarScanner did not complete successfully
##[error]16:27:17.756  Post-processing failed. Exit code: 1
16:27:17.756  Post-processing failed. Exit code: 1
##[error]The process '/usr/bin/dotnet' failed with exit code 1
Finishing: Run SonarCloud analysis

Job is defined as follows

- task: SonarCloudAnalyze@1
      displayName: 'Run SonarCloud analysis'

Prepared job is defined as follows and runs fine

- task: SonarCloudPrepare@1
     inputs:
        SonarCloud: 'SonarCloud - <REDACTED>'
        organization: '<REDACTED>'
        scannerMode: 'MSBuild'
        projectKey: '<REDACTED>'
        projectName: <REDACTED>'
        extraProperties: |
          sonar.inclusions=src/**
          sonar.exclusions=**/Migrations/**/*
          sonar.test.exclusions=tests/**/*
          sonar.verbose=true
          sonar.project.monorepo.enabled=true
          sonar.pullrequest.provider=BitbucketCloud
          sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/${{ replace(variables.solutionLocation, './', '') }}/tests/**/coverage.opencover.xml
          sonar.sensor.cache.project.enable=false
      displayName: 'SonarCloud - Prepare'

It works fine on some projects, but not others.

Hi,

Per the error message:

Since this works for some projects and not others, I’m guessing the SONAR_TOKEN value you’re using was generated by an account that doesn’t have analysis permissions on all your projects.

 
HTH,
Ann

3 posts were split to a new topic: ‘Project not found’ during analysis