Pull Request decoration for GitLab not working

Versions:

SonarQube Developer Edition Version 8.1 (build 31237)
GitLab Community Edition 12.7.5
BuildWrapper version 6.5 (macosx-x86)
SonarQube Scanner 4.2.0.1873
Java 11.0.3 AdoptOpenJDK (64-bit)
Mac OS X 10.14.6 x86_64

We configured the GitLab Pull Request Decoration as described at https://docs.sonarqube.org/latest/analysis/pull-request/

  • Created user in GitLab with Reporter permissions and created Access Token
  • Added GitLab config at Administration > Configuration > General Settings > Pull Request Decoration > GitLab tab
  • Set ALM for project at Administration > General Settings > Pull Request Decoration

We run our scan in GitLab Runner with the following commands
build-wrapper-macosx-x86 --out-dir Builds/SonarQubeOutput bundle exec fastlane standard_build_adhoc
sonar-scanner-macosx/bin/sonar-scanner -Dsonar.pullrequest.key=$CI_MERGE_REQUEST_ID -Dsonar.pullrequest.branch=$CI_COMMIT_REF_NAME -Dsonar.pullrequest.base=master

The scan is successful and a pull request is added to SonarQube.

But the Pull Request Decoration to GitLab is not working. The Pull Request contains an info at the top saying Last analysis had 1 warning and clicking on this shows the following error message:
Pull request decoration did not happen. Github Application configuration is incomplete. Contact your SonarQube administrator to fix it.

As we are using GitLab and only GitLab is configured this message does not make any sence as we are not using Github.

Any advice on how to solve this issue?

Regards Matthias Hager

Welcome to the community. The documentation for GitLab MR decoration you are looking for is here.

You need to remove the arguments sonar.pullrequest.key, sonar.pullrequest.branch, and sonar.pullrequest.base and let the scanner autodetect the CI and the parameters.

Hi, removing the parameters did the trick. We now need to solve a certificate issue with our GitLab instance. But this is not related to SonarQube.

Thanks for your help. Perhaps the documentation should be extended a little bit as on this page https://docs.sonarqube.org/latest/analysis/pull-request/ nothing states the parameters are not needed for GitLab. But I think there is already a task open for this.

Regards Matthias Hager

Glad you managed to get this working. Indeed we already have a pending task to improve this piece of documentation, i pinged our doc geek guru on this matter. Thanks for your suggestion.

I tried to follow the docs with Sonar Scanner for MS Build and it doesn’t seem to support SONAR_HOST_URL and SONAR_TOKEN environment variables, trying to reach SonarQube server on localhost.

Hi Matt,

I am facing the same issue . "Scan is successful and pull request is added " But PR decorations of my Merge Request failing.

Could you please tell me what activities you performed post this.

Thanks
Nitheesh

Hi Niteesh,

I followed Pierres advice and removed the mentioned parameters.

Regards Matthias

Thanks Matt,

I figured it out, The issue bcz of gitlabrunner’s version incompatibility to Gitlab server. we have upgraded to 13.X both the servers and now its working fine.