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