First of all, I know there are a ton of similar post on StackOverflow with regards to this issue, and I have tried the "solutions" that was provided. Which are either use the localhost IP or Sonar Docker IP as the URL in the "Configure System". But both methods does not seem to work in my case. Where did I configure wrong?
Sonar Docker command:
docker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube:latest
Jenkins Docker command:
docker run \
--name jenkins-docker \
--rm \
--detach \
--privileged \
--network jenkins \
--network-alias docker \
--env DOCKER_TLS_CERTDIR=/certs \
--volume jenkins-docker-certs:/certs/client \
--volume jenkins-data:/var/jenkins_home \
--publish 3000:3000 \
--publish 2376:2376 \
docker:dind \
--storage-driver overlay2
Docker Network
Configure System - The "Secret Text" contain the token I got from SonarQube
Global Tool Configuration
Pipeline script
pipeline {
agent any
stages {
stage ('Checkout') {
steps {
git branch:'master', url: 'https://github.com/OWASP/Vulnerable-Web-Application.git'
}
}
stage('Code Quality Check via SonarQube') {
steps {
script {
def scannerHome = tool 'SonarQube';
withSonarQubeEnv('SonarQube') {
sh "${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=OWSAP -Dsonar.sources=."
}
}
}
}
}
post {
always {
recordIssues enabledForFailure: true, tool: sonarQube()
}
}
}
CodePudding user response:
Try to use --network jenkins
while building sonarqube container.
Or donot use --network parameter, its default to use bridge
mode for both containers
Jenkins and Sonarqube should be the same network.
Then try to use http://172.17.0.1:9000
or http://sonarqube:9000
if http://localhost:9000
does not work.