Sonarcloud analysis fails to analyze reports for pull request


for some projects we are using sonar-scanner command to analyze our projects. It is working well for feature and development branch . But unfortunately for some of the projects , MR/PR (pull request) analysis is not working properly.

Here is the error we are facing for pull request analysis . For the records, the pull request is present in open state in our gitlab project . And we have also confirmed correction of SONAR_TOKEN env variable.

INFO: Auto-configuring pull request 44
INFO: ------------------------------------------------------------------------
INFO: Total time: 31.851s
INFO: Final Memory: 20M/70M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
ERROR: Could not find the pullrequest with key '44'
ERROR: Caused by: Error 404 on<PROJECT_KEY>&pullrequestKey=44 : {"errors":[{"msg":"Unable to find the pullrequest with key \u002744\u0027"}]}

Here is the sonar-scanner command
sonar-scanner -X -Dsonar.organization=<ORGANIZATION_KEY> -Dsonar.projectKey=<PROJECT_KEY> -Dsonar.sources=.

Here is my sonar properties


Here is how we have configured pull request analysis.

  <<: *sonarcloud_check
    name: mrit
  needs: ["mr_test"]
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'

Surprisingly, for some of the MRs it is able to push the report and for Some it is failing .

I would be really appreciative for the quick discussion on this topic .

Thanks and Regrads,
Anjali Tandel

We were able to resolve this issue. And I want to share it here so that it can be useful for others.

We tried looking around for this error and figured out that we had added different project to sonarcloud which has same name in our different group under our organization.

As shown in screenshot below, when we try to add a project to sonarcloud , we can see that under our organization , we have multiple projects with same name present .

As there was no differentiator for both of them I made a mistake of selecting any one of them .

Later, We found out that both of them are from two different group. Branch analysis worked as it was a simple sonar-scanner push but when we tried pushing pull request analysis , it was not able to find out that particular PR.

From following screenshot below, when we clicked on gitlab symbol ,we were able to figure out under what group the project is present.

I hope it helps.


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