Error integrating SonarQube into CI pipeline

I need help on solving this issue. Can anybody help me ??

I have installed sonarqube in /opt/sonar and configured sonar.properties in /opt/sonar/conf. I have also installed sonarscanner 4.2v in /opt/sonar-scanner folder,configured sonar-scanner.properties in /opt/sonar-scanner/conf. both of these scanner has sonar.host.url = ‘http://MYVMIP:9000’ along with web.host and web.port uncommented for respective values.
I have installed gitlab runner. confuigured cicd variables[SONAR_LOGIN,SONAR_PASSWORD].

/etc/profile.d has sonar-scanner.sh file that has path for both of the above files. ‘source /etc/profile.d/sonar-scanner.sh’. sonar.service file written in /etc/systemd/sytem. User has been added, permission is given.

NOTE : i have not installed Docker on my machine.

Sonar portal is accessible on http://MYVMIP:9000, but if i run my pipeline code
sonarqube-check:
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [“”]
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
cache:
key: “${CI_JOB_NAME}”
paths:
- .sonar/cache
script:
- sonar-scanner -X
allow_failure: true
only:
- master
this is throwing error.

Please guide me

Hi,

This does not look like a GitLab issue, this is purely a network problem (SQ CLI cannot reach SQ Server). You didn’t specify - are you using gitlab.com Runners or your own Runners?

You need to make sure that your GitLab Runners can reach your SonarQube instance via provided IP as well. For simple debugging you could e.g. try to curl your SQ instance from a Runner.

@paula.kokic Im not using available default runners of Gitlab. Im using self configured runners from gitlab.
Can please ellaborate on how to check connectivity from gitlab runner to SQ? I can access SQ rom the IP on which it is installed. But im unaware of checking it through gitlab runner. Pls share knowledge

Hi,

Depends a bit what type of Runners you have and how did you install them.

Assuming you have a basic Runner installed using Linux packages on a single VM, you could ssh into that VM and try to curl your SQ server:

curl http://<your-sonarqube-instance-ip>:9000

Curl is happening from runner vm. Issue persists. Can we have runner and SQ installed on same VM? @paula.kokic

In theory, yes.

But GitLab recommends installing Runner on a dedicated VM. And I would advise you to do so as well. Otherwise you might have performance issues.

If you don’t have the same issue with curl, you could dig deeper with other network tools. Google is your best friend.

If you’re working in the company, I would advise you to get in contact with your Network/Security Team to check the configuration / requirements.

1 Like