# SonarCloud Pull Request Analysis fon GitHub Error

**URL:** <https://community.sonarsource.com/t/sonarcloud-pull-request-analysis-fon-github-error/29290>\
**Category:** SonarQube Cloud\
**Tags:** java, sonarqube-cloud\
**Created:** [August 10, 2020, 4:12am UTC](https://community.sonarsource.com/t/sonarcloud-pull-request-analysis-fon-github-error/29290 "2020-08-10T04:12:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SudharakaP](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/sudharakap/32/14067_2.png) [@SudharakaP](https://community.sonarsource.com/u/SudharakaP)\
**Post date:** [August 10, 2020, 4:12am UTC](https://community.sonarsource.com/t/sonarcloud-pull-request-analysis-fon-github-error/29290/1 "2020-08-10T04:12:36Z")

</div>

Hi there,

I have been trying to setup SonarCloud Pull request analysis for a GitHub repos of ours. The pull request analysis seems to work fine with the pull request source branch is in the original repo; but when the pull request is created from a fork it seems to fail with the following error;

```auto
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project jhonline: Parameter 'sonar.pullrequest.branch' is mandatory for a pull request analysis -> [Help 1]

```

Below is a GitHub action triggered by a pull request where this failure can be seen;

> <https://github.com/jhipster/jhipster-online/pull/214/checks>
>
> This fixes some remaining vulnerabilities and code smells.
> 
> Related to https:/…/github.com/jhipster/jhipster-online/issues/209

Also I tried adding the `sonar.pullrequest.branch` as the error suggests. Then I get a different error;

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

```

The CI run relevant to adding the `sonar.pullrequest.branch` can be found here; [fix: add correct head ref · jhipster/jhipster-online@60e369e · GitHub](https://github.com/jhipster/jhipster-online/runs/965109060)

I also saw that there is [another thread for gradle](https://community.sonarsource.com/t/sonarcloud-circleci-and-graldle-failed-with-sonar-pullrequest-branch-is-mandatory-for-a-pull-request-analysis/20855) which has a similar error; but not sure if this one and that one are the same thing.

Any help on this will be greatly appreciated.

Thank you,  
Sudharaka.

---

<div class="post-metadata">

**Author:** ![TomVanBraband](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tomvanbraband/32/46480_2.png) [@TomVanBraband](https://community.sonarsource.com/u/TomVanBraband)\
**Post date:** [August 10, 2020, 6:59am UTC](https://community.sonarsource.com/t/sonarcloud-pull-request-analysis-fon-github-error/29290/2 "2020-08-10T06:59:48Z")

</div>

Hello @SudharakaP,

I think both issues you have are related having an incorrect SONAR\_TOKEN. The most probable explanation is that the user that generated the [SONAR\_TOKEN environment variable](https://github.com/SudharakaP/jhipster-online/blob/deeefed1a1339a8fdb6fbb10fd168d745dc65717/.github/workflows/github-ci.yml#L71) does not have the permission to scan the project.

You can generate a new token [here](https://sonarcloud.io/account/security/), if you’re part of the jhipster organization on SonarCloud you can check which users have the correct permissions [here](https://sonarcloud.io/organizations/jhipster/members).

Hope that helps

---

<div class="post-metadata">

**Author:** ![SudharakaP](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/sudharakap/32/14067_2.png) [@SudharakaP](https://community.sonarsource.com/u/SudharakaP)\
**Post date:** [August 10, 2020, 7:15am UTC](https://community.sonarsource.com/t/sonarcloud-pull-request-analysis-fon-github-error/29290/3 "2020-08-10T07:15:29Z")

</div>

@TomVanBraband: Thanks much for your quick response. Appreciate it. Sure I can try changing the token; but I am wondering then why does it only not working for pull requests from forks? The pull requests created within the repo branches (not from forks) seems to work fine. If the token is wrong shouldn’t it be not working for both cases? 🤔

---

<div class="post-metadata">

**Author:** ![TomVanBraband](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tomvanbraband/32/46480_2.png) [@TomVanBraband](https://community.sonarsource.com/u/TomVanBraband)\
**Post date:** [August 10, 2020, 7:56am UTC](https://community.sonarsource.com/t/sonarcloud-pull-request-analysis-fon-github-error/29290/4 "2020-08-10T07:56:20Z")

</div>

You are right, I did not see that it only fails for external PRs.  
GitHub does not make secrets available for external PRs (from forked projects). This is to prevent people from stealing the secrets by just logging them to sysout.

We currently do not support an analysis that was triggered from an external PR, but we are planning to do so in the future. You can follow the progress on [this ticket](https://jira.sonarsource.com/browse/MMF-1371).

---

<div class="post-metadata">

**Author:** ![SudharakaP](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/sudharakap/32/14067_2.png) [@SudharakaP](https://community.sonarsource.com/u/SudharakaP)\
**Post date:** [August 11, 2020, 2:27am UTC](https://community.sonarsource.com/t/sonarcloud-pull-request-analysis-fon-github-error/29290/5 "2020-08-11T02:27:31Z")

</div>

@TomVanBraband : Thanks much for the information. 😄

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [August 18, 2020, 2:27am UTC](https://community.sonarsource.com/t/sonarcloud-pull-request-analysis-fon-github-error/29290/6 "2020-08-18T02:27:38Z")

</div>

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