Our pipelines have been running smoothly every day without any issues, but suddenly, we are encountering problems with the Sonar execution during Merge Requests.
ERROR Project not found. Please check the ‘sonar.projectKey’ and ‘sonar.organization’ properties, the ‘SONAR_TOKEN’ environment variable, or contact the project administrator to check the permissions of the user the token belongs to.
However, we have the project key and organization name defined in the sonar-project.properties file, and the token and host are set in the GitLab CI/CD variables.
If the issue appears only in Pull/Merge Request pipelines, then most likely the token set in your global Administration > Organization Settings > Organization binding is no longer valid. This token is used to query information about the pull/merge request during analysis.
(and yes, it’s very annoying that the error message isn’t more clear about this :()
I believe the issue isn’t with the token, as it works fine with feature branches. The problem seems to occur only during merge requests, where the pipelines are failing.
I’m also providing analysis logs, sensitive information was replaced with placeholders.
The logs provided are from a CI pipeline that analyses code from PR
This looks like a different issue than the one @seetharam is describing (at least, there’s a different error message).
Usually this message is the result of using a project key that doesn’t exist on SonarQube, and where the first analysis of a pull request/short-lived branch.
Consider this log message:
2025-02-11T11:15:05.1229900Z 11:15:05.122 DEBUG --> GET https://sonarcloud.io/api/project_branches/list?project=*****
Does that (redacted) project key match the project key in the URL when you browse this project on SonarCloud?
Does visiting https://sonarcloud.io/api/project_branches/list?project=***** (unredacted of course) return valid data?
I’d also want to know if this token being used in the service account generated using the same account you’ve used to log into SonarCloud (and browsed the URL with), or another account?