this is nianjun from Apache/ShardingSpehere project.
recently we add the sonarcloud job for analyze the code quality, and all analysis scheduled in night were sucess, so we decide to add sonarcloud analyze to pull_request action.
but it’s a little bit strage, all sonarcloud action triggered by pull_request failed, but for the same action , if triggered by workflow_dispatch(manually luanch) will sucess
not sure if there is any problem with this action.
Can you share the analysis log for one of these failures?
The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.
thanks for your attention, the error is as followings:
Error: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project shardingsphere: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator -> [Help 1]
and after read the most of the maven log, I found something interesting
the log of maven triggered by pull request getting something wrong with check bound:
[INFO] Project key: pawellabaj:auto-record
(...)
[INFO] Check ALM binding of project 'pawellabaj:auto-record'
Warning: Failed to check if project 'pawellabaj:auto-record' is bound
[INFO] Detected project binding: ERROR
[INFO] Check ALM binding of project 'pawellabaj:auto-record' (done) | time=811ms
(...)
[INFO] Organization key: pawellabaj
[INFO] Branch name: dependabot/maven/org.jacoco-jacoco-maven-plugin-0.8.10, type: short-lived
(...)
Error: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default) on project auto-record: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator -> [Help 1]
When I run workflow manually on this branch, everything is fine.
When I checkout the branch on the local machine and run maven verification, everything is fine.
It looks like either your PR analysis isn’t getting the basic settings (e.g. sonar.projectKey or the envvar SONAR_TOKEN isn’t being set in that environment.
@pawellabaj please do create a new thread. (And welcome to the community! )
In addition, everything is fine, when I execute the workflow manually with workflow_dispatch event. In both cases, the workflow uses the same pom.xml and env variables from GitHub secrets.
in fact, the SONAR_TOKEN and project related info are set in workflow yml file. if not set these info, the nightly build or mannually build will not success.