PR analysis for original repo which doesn't have SonarCloud project

Hello,
I use GitHub actions and Maven. I have forked repo that is configured with SonarCloud project. The original repo doesn’t have SonarCloud project. what I want is I want to trigger PR analysis when PR is made to the original repo not the forked repo. Is that possible?

Hello,

No this is not supported, if you fork a repo and import it in SonarCloud then only PR on this forked repo will get analyzed and decorated by SonarCloud.

If you want your PRs to the original repo to be analyzed then you need to ask the maintainer of that repo to configure SonarCloud on it.

Thanks for your reply. suppose now that the maintainer of the original repo configured SonarCloud on it,and the PR is analyzed, then he accepts the PR and master branch analysis is triggered and everything works fine. what happens to GitHub checks on master branch of my forked repo when I pull the new changes to the master? will it fail? how can I make it succeed?

Well if you have the same configuration on SonarCloud than the original repo there is no reason that it would fail on the forked repo since it’s the same code that will be analyzed.

Okay. the original repo has now SonarCloud project, I made a PR from my forked repo to it, but the checks also fail. I get this in the logs:

[WARNING] Unable to analyse file ‘pom.xml’.
java.lang.IllegalStateException: You’re not authorized to run analysis. Please contact the project administrator.

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project test-sonar: null: MojoExecutionException: NullPointerException → [Help 1]

It now says:

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project test-sonar: You’re not authorized to run analysis. Please contact the project administrator. → [Help 1]

the forked repo maintainer has execute analysis permission, but PR analysis fails. what is the problem and how can I fix it?

I’m not sure I’m correct but my understanding is that you have two private repositories, and one is a fork from the first one. And you are trying to do external PR from the fork to the original repo and get this PR analyzed.
If this is the case, it’s unfortunately not supported yet in Autoscan, analysis of external PR only work on public repo for now.

yes you are right except that two repos are public not private. I solved the problem by configuring SonarCloud project with the original repo, and any PR from forked repo to original repo will be analyzed now. Thank you for your response