SonarQube server can not be reached by Jenkins using Docker

I have added a SonarQube Scanner analysis step to my Jenkins build, but the step fails:

[Test_gitlab] $ /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/http_INTERNAL_DOCKER_IP_ADDRESS_9000/bin/sonar-scanner -e -Dsonar.host.url=SERVER_IP_ADDRESS:9000 ******** -Dsonar.projectBaseDir=/var/jenkins_home/workspace/Test_gitlab
INFO: Option -e/--errors is no longer supported and will be ignored
INFO: Scanner configuration file: /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/http_INTERNAL_DOCKER_IP_ADDRESS_9000/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 2.8
INFO: Java 1.8.0_102 Oracle Corporation (64-bit)
INFO: Linux 3.10.0-327.10.1.el7.x86_64 amd64
INFO: User cache: /var/jenkins_home/.sonar/cache
ERROR: SonarQube server [SERVER_IP_ADDRESS:9000] can not be reached
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 0.214s
INFO: Final Memory: 4M/209M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQube
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:84)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:71)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:71)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:67)
    at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:218)
    at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:156)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:72)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Fail to download libraries from server
    at org.sonarsource.scanner.api.internal.Jars.downloadFiles(Jars.java:93)
    at org.sonarsource.scanner.api.internal.Jars.download(Jars.java:70)
    at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:39)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:75)
    ... 8 more
Caused by: java.lang.IllegalArgumentException: unexpected url: SERVER_IP_ADDRESS:9000/batch_bootstrap/index
    at org.sonarsource.scanner.api.internal.shaded.okhttp.Request$Builder.url(Request.java:141)
    at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:109)
    at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:98)
    at org.sonarsource.scanner.api.internal.Jars.downloadFiles(Jars.java:78)
    ... 11 more
ERROR: 
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
ERROR: SonarQube scanner exited with non-zero code: 1
Finished: FAILURE

My SonarQube Scanner is declared in Jenkins Global Tool Configuration. The name used is “http://SERVER_IP_ADDRESS:9000”. This is the same address as the server base URL that I have set within SonarQube General Settings.

  • Gitlab run docker inside docker
  • why did the pulling process in docker act like this?
  • symfony docker permission problems for cache files
  • How to deal with state “Exit 0” in Docker
  • How to read and write to mounted volume without running as root?
  • Run graphical process in Docker container, detach and reconnect to the running GUI
  • I’m using Docker: Jenkins is in a Docker container, and so does SonarQube.

    The “unexpected url” mentioned in the stacktrace SERVER_IP_ADDRESS:9000/batch_bootstrap/index can be opened in a browser,
    which displays sonar-scanner-engine-shaded-6.1.jar|SOME_LETTERS_AND_NUMBERS.
    So why can’t Jenkins reach the server?

    I’ve also tried with Docker internal IP address, that can be found with:

    docker inspect SONARQUBE_CONTAINER_ID | grep IP
    

  • Rethinkdb race conditions creating table
  • Hapi.js is not listening to subdomains?
  • Error starting docker postgres on travis-
  • Insufficient scope when attempting to get Docker Hub catalog
  • Restricting access to a Docker container
  • Docker Maven Spotify plugin - Possible to switch to non-secure registry
  • One Solution collect form web for “SonarQube server can not be reached by Jenkins using Docker”

    Find place where you define the “unexpected url” mentioned in the stacktrace (parameter sonar.host.url of SonarQube Scanner) and prefix it with http://.

    URLs must start with a scheme – see Wikipedia. Browser simply adds http:// by default.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.