Hello,
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: EXECUTION FAILURE
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 https://sonarcloud.io/api/alm_integration/show_pullrequest?project=<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=. -Dsonar.host.url=https://sonarcloud.io
Here is my sonar properties
sonar.projectKey=<PROJECT_KEY>
sonar.organization=<ORGANIZATION_KEY>
sonar.host.url=https://sonarcloud.io
sonar.projectName=<PROJECT_NAME>
sonar.projectVersion=1.0
sonar.sources=modules/*/src
sonar.sourceEncoding=UTF-8
sonar.java.binaries=.
Here is how we have configured pull request analysis.
mr_sonarcloud_check:
<<: *sonarcloud_check
environment:
name: mrit
needs: ["mr_test"]
rules:
- 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