Sonarqube and gitlab integration error

I am using Community Edition of Sonarqube.
I very new in sonarqube and gitlab. I need to integration with sonar and gitlab but I am getting this error.
I try to add project from my repository with gitlab CI and Sonarqube gives me .gitlab-ci.yml content.
when I commit .gitlab-ci.yml script I am getting this error.

Please help me.

Hi @tugbaOzturk and welcome to our community :slight_smile:
Can you tell me which build technology are you using (Maven, .NET, Gradle, etc)?
From what I understand, the only yml we provide with an apt-get command is the one from .NET. But there is no apt-get install gitlab-runner command in what we provide.

Can you provide us the yml file you use?

Kind regards,

Hello Chiritophe,
Thank you for reply. I am using .NET. Of course i can provide the yml file.

Processing: gitlab-ci.yml…
image: GitHub - microsoft/containerregistry: Microsoft Container Registry description and related FAQ
SONAR_USER_HOME: “${CI_PROJECT_DIR}/.sonar” # Defines the location of the analysis task cache
GIT_DEPTH: “0” # Tells git to fetch all the branches of the project, required by the analysis task
key: “${CI_JOB_NAME}”
- .sonar/cache
- sonar.qualitygate.wait=true
- “apt-get update”
- “apt-get install --yes openjdk-11-jre”
- “dotnet tool install --global dotnet-sonarscanner”
- “export PATH=”$PATH:$HOME/.dotnet/tools""
- “dotnet sonarscanner begin /k:“gitlabdeneme_deneme_AXrmxi8qyRN88oGWNdos” /d:sonar.login=”$SONAR_TOKEN" /d:“$SONAR_HOST_URL” "
- “dotnet build”
- “dotnet sonarscanner end /d:sonar.login=”$SONAR_TOKEN""
allow_failure: true
- master # or the name of your main branch

Hello @tugbaOzturk

Could you please share with us what operating system are you using? I assume that apt-get is not installed on your OS.

Hello, @Caba_Sagi @Christophe_Havard
I am using linux centos for my runner and and gitlab.
Is there any way convert this script for linux centos ?

Thank you for your reply.


I did a bit of research and according to it the default package manager used in CentOS is yum. So, If you change from apt-get to sudo yum, it should solve your problem.

Thank you , I am gonna try to run script with sudo yum.
I get same error also for this line - “dotnet tool install --global dotnet-sonarscanner” (dotnet: command not found)
What should I use for dotnet ?

It seems to me that you don`t have dotnet installed on the machine. Please take a look at the Microsoft guide for installing dotnet on CentOs.

Hello @tugbaOzturk

Did you manage to make it work?