3

I have Gitlab Community and I am trying to integrate it with SonarQube. The Sonar is hosted on Azure VM Ubuntu in a Docker container. The problem is that I really don't know how to write gitlab-ci.yml. I already try sonar, but locally hosted on a Windows machine. Here is my current gitlab-ci.yml.

When I change sonar host with my current and I am not sure what I need to put on sonar. Login then throws an error:

SonarScanner for MSBuild 5.0.4
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
18:35:07.168 Updating build integration targets...
18:35:07.394 The token you provided doesn't have sufficient rights to check license.

sonar-check:
  image:
    name: sonarsource/sonar-scanner-cli:latest
    entrypoint: [""]
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - .sonar/cache
  dependencies:
    - build
  script:
    - choco install sonarqube-scanner.portable
    - SonarScanner.MSBuild.exe begin /k:"somefile" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="8f6658e7684de225a4f45c7cf3466d462a95c1c7"   
    - nuget restore -ConfigFile .\nuget.config
    - MsBuild.exe ./Process /t:Rebuild
    - SonarScanner.MSBuild.exe end /d:sonar.login="8f6658e7684de225a4f45c7cf3466d462a95c1c7"
  only:
    - merge_requests
    - master
    - develop
    - GitLabQualityTool
Anatoly
  • 20,799
  • 3
  • 28
  • 42

4 Answers4

4

For anyone coming here for a similar problem where you had things set up correctly and suddenly they stopped working, I just experienced this. I had to generate a new auth token and that got things working correctly. I don't have an explanation for why that occurred though, but this is a troubleshooting step one could take.

nibudd
  • 56
  • 3
4

Maybe your SonarQube scanner is out of date

I faced the Same Issue Error Message

I solved this issue by this command dotnet tool update --global dotnet-sonarscanner

enter image description here

And it worked right after

enter image description here

2

I found the solution. You need to go to your sonar MyAccount->Security->Generate Token. This token must be added here:

- SonarScanner.MSBuild.exe begin /k:"somefile" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="8f6658e7684de225a4f45c7cf3466d462a95c1c7" 
- SonarScanner.MSBuild.exe end /d:sonar.login="8f6658e7684de225a4f45c7cf3466d462a95c1c7"

and your sonar URL.

0

make sure when you do create Ci file for sonar scan then u need to check which image are you using because for sonar 10.x version we are using sonar.token parameters instead of sonar.login so either your token is correct you will get issue because if use old image with sonar 10.x version you will get issue like token issue in my case i have update sonar 10.x and i was using my customize image which old used by sonar 9.x . make user this points to avoid such silly issue's

Wajid Shaikh
  • 339
  • 3
  • 5