Dockerized Jenkins and Sonarqube – Link to analysis in project incorrect
I’m running Jenkins and SonarQube in containers on Debian. The Jenkins image is started with the options
--link sonar:sonar where sonar is the name of the running Sonar container. Hence, Jenkins’s /ets/hosts contains a hostname entry pointing to the ip of the dockerized Sonar. In the Sonar-config section (in Jenkins), sonar:9000 is entered as the Sonar server.
When building, the scanner runs as expected, but the Sonar-link in the project page contains the internal Docker-address, i.e. sonar:9000! This address is meaningless outside Docker. I want the link to point to the host machine. When I navigate directly to the host, port 9000, I am able to see Sonar’s analysis.
How can I separate the url to Sonar which is used by Jenkins in the build process and the url which is displayed in the project-build page?
Here is a screenshot from the Project Build page in Sonar build page
The Sonarcube link is pointing to the URL which is set in Manage Jenkins->Configure System under Sonarqube Servers. In this instance, the url is sonar:9000, which is the hostname that is known for the container running Jenkins. This URL is meaningless outside of the container. It should be possible to enter one internal URL for the server and one external for the Jenkins users.