SonarQube Docker image Community edition 8.7.0, Sonar Scanner latest image
I have setup sonarqube in a docker container. After adding the sonar-check stage in Gitlab CI, the scanner is not executing the stage properly. Gitlab Runner is running on the docker environment.
following error is being thrown:
/bin/bash: line 118: docker: command not found
My guess runner is trying to execute the docker info command inside sonarscanner docker image.
Steps to reproduce:
Setup ur project on sonarqube.
Configure Analysis with Gitlab CI
Build Technology Other
Configure sonar-project.properties file
Add other environment variables
Copy gitlab configuration from sonarqube, paste it in .gitlab-ci.yml file.
If I understand correctly, you are running Gitlab Runner in a docker container, and try to use the docker scanner image. That means that your dockerized Gitlab Runner needs to be able to spawn other docker containers, with a privileged mode.
If my understanding is correct, then what you need is to enable the dind service, for Docker IN Docker. Documentation is here
Unfortunately same error, even though my runners are running in privileged mode and I have added the
services:
- docker:dind
line in my gitlab yml file
sonarqube-check:
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
services:
- docker:dind
variables:
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
SONAR_HOST_URL: ${SONAR_HOST_URL}
SONAR_TOKEN: ${SONAR_TOKEN}
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- sonar-scanner
allow_failure: true
only:
- master # or the name of your main branch