Seeing "ERROR: Project not found." When using github actions for first time

  • ALM used: Github
  • CI system used: Github Actions
  • Scanner command used: sonar-scanner --define sonar.cfamily.build-wrapper-output=“${{ env.BUILD_WRAPPER_OUT_DIR }}”
  • Languages of the repository: C++
  • SonarCloud project: SonarCloud
  • Error observed: “ERROR: Project not found.”
  • Steps to reproduce: Run sonar scanner in any CI build
  • Potential workaround: None

I am interested in trying out Sonar Cloud for a repository of mine, but when I attempt to run the analysis, the scanner step fails with the following error:

INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 3:39.727s
ERROR: Error during SonarScanner execution
INFO: Final Memory: 35M/120M
ERROR: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator
INFO: ------------------------------------------------------------------------
ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
Error: Process completed with exit code 1.

I confirmed that, in fact, the sonar.projectKey, sonar.organization values have been set in the sonar project properties file, following the instructions from the “Configure” → “With GitHub Actions” page. I also confirmed I have entered the SONAR_KEY as a repository secret using those same instructions.

Here are the files I’m using (based off of the example windows-cmake-gh-actions-sc project):

Sonar Project Properties File:

Workflow File:

And here is the full Github Action Execution:

Github Action Run:

I was hoping someone may have seen an issue like this before, or have an idea of something I could have missed during the initial setup. Please let me know if there are any other relevant details I can help provide.

Hello @StephenLHern, and welcome to the community,

I have taken the liberty of forking your project and doing a run (I hope you don’t mind), and it worked (see here the report). Therefore, the workflow is correctly setup.

Perhaps there is a typo, or a C&P mistake on the secret configuration. I would suggest double-checking that the secret is really named SONARCLOUD_TOKEN (since you mention SONAR_KEY and the documentation says SONAR_TOKEN). If the name is OK, then I would try regenerating the token on SonarCloud and updating the value on GitHub.

Of course, I had to modify both sonar.projectKey and sonar.organization to get my repo working, but they look correct on your side to me.

Let me know if this helps.

Thank you Alejandro Álvarez Ayllón!

I followed the documentation directly from my sonar cloud’s configuration page, and named the secret “SONAR_TOKEN”:

By changing the name to SONARCLOUD_TOKEN as you suggested, I was able to successfully complete an analysis.

My original post included a typo, I wrote that I named the secret “SONAR_KEY” but I did confirm I had actually used “SONAR_TOKEN” and that this doesn’t appear to work.

I wonder if the documentation linked on the sonar cloud website is outdated or intended for users running the tool with their own server or something.

Good point. I will note this need to be synchronized.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.