使用jenkins时无法找到sonarqube

问题描述 投票:0回答:2

我正在使用 jenkins,我需要我的 sonarqube 对我的代码进行一些分析。

我使用 docker 来管理这两个映像并映射端口,以便可以从外部访问它们。效果很好,我可以在两个门户中打开并登录。

我的问题是,当我尝试运行我的 jenkins 构建并向 sonarqube 询问信息时,它会抛出以下错误:

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:70)
    at org.sonarsource.scanner.cli.Main.main(Main.java:60)
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.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.Platform.connectSocket(Platform.java:101)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.Connection.connectSocket(Connection.java:198)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.Connection.connect(Connection.java:172)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.Connection.connectAndSetOwner(Connection.java:358)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:117)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:329)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.Call.getResponse(Call.java:276)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:234)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.Call.getResponseWithInterceptorChain(Call.java:196)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.Call.execute(Call.java:79)
    at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:114)
    at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:99)
    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.
Build step 'Execute SonarQube Scanner' marked build as failure
Finished: FAILURE

我完全不知道这里出了什么问题。

我做了什么:

  • 我已经在sonarqube中的“user=>token=>generate a token for user”中注册了一个服务器密钥,并在我的jenkins应用程序中使用它
jenkins sonarqube sonarqube-ops
2个回答
1
投票

此错误意味着您的 Jenkins 服务器无法访问您的声纳服务器。可能是IP或者域名设置错误。也许它们之间的网络设置不正确。

在 Jenkins 控制台日志中的某个位置,您应该会看到类似以下内容:

Injecting SonarQube environment variables using the configuration: Sonarqube Local
[workspace] $ mvn sonar:sonar -Dsonar.host.url=http://sonar.yourserver.com -Dsonar.login=******

确保 sonar.host.url 设置正确。然后确保您可以从您的詹金斯服务器访问它。


0
投票

是的,这是由于我的sonarqube服务器设置错误造成的,我已经解决了这个问题,并尝试了另一种方式使用docker来运行sonarqube服务器,我附上了下面的安装步骤。

如何安装SonarQube

  1. docker 拉 SonarQube
  2. docker run -d --name sonarqube-db -e POSTGRES_USER=sonar -e POSTGRES_PASSWORD=sonar -e POSTGRES_DB=sonarqube postgres:alpine
  3. docker run -d --name sonarqube -p 9000:9000 --link sonarqube-db:db -e SONAR_JDBC_URL=jdbc:postgresql://db:5432/sonarqube -e SONAR_JDBC_USERNAME=sonar -e SONAR_JDBC_PASSWORD=sonar sonarqube
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.