无法访问 SonarQube 服务器 [https://sonar.example.org]

Posted

技术标签:

【中文标题】无法访问 SonarQube 服务器 [https://sonar.example.org]【英文标题】:SonarQube server [https://sonar.example.org] can not be reached 【发布时间】:2021-07-03 00:54:44 【问题描述】:

在我的情况下,我的 Jenkins 有两个节点。一个作为主节点,其他节点作为从节点。另外,我有一个单独的实例用于在 SonarQube 上运行。

我有一个内部证书颁发机构。我用它来签署我的证书。另外,我使用 keytool 将此 CA 证书添加到 Jenkins java 实例可信存储中。我使用SSLPoke.验证了我的作品

但问题是,当我使用 SonarQube 分析运行作业时,它失败并出现以下错误,谁能帮我解决这个问题。

Started by user admin
Running as SYSTEM
Building remotely on centos7-slave in workspace /home/jenkins/workspace/BXGRN/UAT/UAT_SONAR
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Deferred wipeout is used...
[WS-CLEANUP] Done
The recommended git tool is: NONE
No credentials specified
Cloning the remote Git repository
Cloning repository git@github.com:example-ict/warehouse.git
 > git init /home/jenkins/workspace/BXGRN/UAT/UAT_SONAR # timeout=10
Fetching upstream changes from git@github.com:example-ict/warehouse.git
 > git --version # timeout=10
 > git --version # 'git version 1.8.3.1'
 > git fetch --tags --progress git@github.com:example-ict/warehouse.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url git@github.com:example-ict/warehouse.git # timeout=10
 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
Avoid second fetch
 > git rev-parse refs/remotes/origin/master^commit # timeout=10
Checking out Revision 2b11909dea58f3e107ff0c78338b33e76d4beb47 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 2b11909dea58f3e107ff0c78338b33e76d4beb47 # timeout=10
Commit message: "UI URL change"
 > git rev-list --no-walk 2b11909dea58f3e107ff0c78338b33e76d4beb47 # timeout=10
[UAT_SONAR] $ /home/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/Sonar_Runner/bin/sonar-scanner -Dsonar.host.url=https://sonar.example.org ******** -Dsonar.sourceEncoding=UTF-8 -Dsonar.typescript.lcov.reportPaths=coverage/lcov.info -Dsonar.sources=./ -Dsonar.language=js -Dsonar.exclusions=src/serviceWorker.js,src/Routes.js,src/index.js -Dsonar.projectVersion=36 -Dsonar.projectKey=bxgrn -Dsonar.verbose=true -Dsonar.log.level=DEBUG -Dsonar.test.inclusions=**/src/**/*.test.js,**/src/**/*.test.jsx -Dsonar.projectName=BXGRN -Dsonar.projectBaseDir=/home/jenkins/workspace/BXGRN/UAT/UAT_SONAR
INFO: Scanner configuration file: /home/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/Sonar_Runner/conf/sonar-scanner.properties
INFO: Project root configuration file: /home/jenkins/workspace/BXGRN/UAT/UAT_SONAR/sonar-project.properties
04:43:34.094 INFO: SonarScanner 4.6.0.2311
04:43:34.096 INFO: Java 9.0.4 Oracle Corporation (64-bit)
04:43:34.096 INFO: Linux 3.10.0-1127.19.1.el7.x86_64 amd64
04:43:34.238 DEBUG: keyStore is : 
04:43:34.238 DEBUG: keyStore type is : pkcs12
04:43:34.238 DEBUG: keyStore provider is : 
04:43:34.239 DEBUG: init keystore
04:43:34.239 DEBUG: init keymanager of type SunX509
04:43:34.372 DEBUG: Create: /home/jenkins/.sonar/cache
04:43:34.373 INFO: User cache: /home/jenkins/.sonar/cache
04:43:34.373 DEBUG: Create: /home/jenkins/.sonar/cache/_tmp
04:43:34.376 DEBUG: Extract sonar-scanner-api-batch in temp...
04:43:34.379 DEBUG: Get bootstrap index...
04:43:34.379 DEBUG: Download: https://sonar.example.org/batch/index
04:43:34.542 ERROR: SonarQube server [https://sonar.example.org] can not be reached
04:43:34.542 INFO: ------------------------------------------------------------------------
04:43:34.542 INFO: EXECUTION FAILURE
04:43:34.542 INFO: ------------------------------------------------------------------------
04:43:34.542 INFO: Total time: 0.489s
04:43:34.559 INFO: Final Memory: 3M/12M
04:43:34.559 INFO: ------------------------------------------------------------------------
04:43:34.559 ERROR: Error during SonarScanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarScanner analysis
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:85)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:74)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:70)
    at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:185)
    at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:123)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:73)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server
    at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:42)
    at org.sonarsource.scanner.api.internal.JarDownloader.getScannerEngineFiles(JarDownloader.java:58)
    at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:53)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:76)
    ... 7 more
Caused by: javax.net.ssl.SSLPeerUnverifiedException: Hostname sonar.example.org not verified:
    certificate: sha256/efcGoaHuyZ3CK/sYVfBRQroEdq92kUq4ygagx2CcHz0=
    DN: CN=sonar.example.org, OU=Infrastructure, O=example (Private) Limited, L=Colombo, ST=Western Province, C=LK
    subjectAltNames: []
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connectTls(RealConnection.java:350)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.establishProtocol(RealConnection.java:300)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connect(RealConnection.java:185)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.java:224)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.java:108)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.find(ExchangeFinder.java:88)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.Transmitter.newExchange(Transmitter.java:169)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:41)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.getResponseWithInterceptorChain(RealCall.java:221)
    at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.execute(RealCall.java:81)
    at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:115)
    at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:99)
    at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:39)
    ... 10 more
04:43:34.561 ERROR: 
04:43:34.561 ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeed?
ERROR: SonarQube scanner exited with non-zero code: 1
Finished: FAILURE

【问题讨论】:

好吧。 URL https://sonar.example.org 不正确。它不存在! 它不会暴露在互联网上@Seelenvirtuose。它仅在内部网络上工作。这也不是一个实际的域。 “example.org”是模拟域 您认为,省略这些基本信息可以吗?您甚至查看了错误消息吗?您有以下错误:“SSLPeerUnverifiedException:主机名 sonar.example.org 未验证:” 我无法公开发布该域。这是我公司的政策评估,为什么我使用 exmple.org 替换域......此外,我当前的域名可以在内部解析,当我使用 curl 命令访问 SonarQube 时,它​​按预期工作。(在这个特定的奴隶上)唯一的问题是它在运行 Jenkins 作业时不起作用。 【参考方案1】:

问题出在我的证书上;我需要将 SAN 添加到特定域名 (sonar.example.org)。使用 SAN 创建新证书后,一切都按预期进行。

【讨论】:

以上是关于无法访问 SonarQube 服务器 [https://sonar.example.org]的主要内容,如果未能解决你的问题,请参考以下文章

错误:无法访问 SonarQube 服务器 [http://localhost:9000]

服务器无法访问到 Jenkins 的 SonarQube Webhook

Jenkins 无法使用带有自签名证书的 HTTPS (HTTP + SSL) 连接到 SonarQube 服务器

Maven Sonarqube 插件:无法执行 SonarQube:无法从服务器获取引导索引

Sonarqube C# MsBuild 访问被拒绝

无法在Windows上将SonarQube 5.3作为服务运行