docker下jenkins集成sonar,扫描报错

使用jenkins自动化SonarQube源码扫描 - 知乎 根据帖子配置完成:jenkins集成gitee配置的sonar扫描freestyle工程


报错日志:
Started by user scsc1202
Running as SYSTEM
Building on master in workspace /var/jenkins_home/workspace/sonar
The recommended git tool is: NONE
using credential 6e0dd5ac-ba54-4e65-bec4-a19486bcb331
Cloning the remote Git repository
Cloning repository test_Wework.py: Gitee.com(码云) 是 OSCHINA.NET 推出的代码托管平台,支持 Git 和 SVN,提供免费的私有仓库托管。目前已有超过 600 万的开发者选择 Gitee。

git init /var/jenkins_home/workspace/sonar # timeout=10
Fetching upstream changes from test_Wework.py: Gitee.com(码云) 是 OSCHINA.NET 推出的代码托管平台,支持 Git 和 SVN,提供免费的私有仓库托管。目前已有超过 600 万的开发者选择 Gitee。
git --version # timeout=10
git --version # ‘git version 2.11.0’
using GIT_ASKPASS to set credentials
git fetch --tags --progress – test_Wework.py: Gitee.com(码云) 是 OSCHINA.NET 推出的代码托管平台,支持 Git 和 SVN,提供免费的私有仓库托管。目前已有超过 600 万的开发者选择 Gitee。 +refs/heads/:refs/remotes/origin/ # timeout=10
git config remote.origin.url test_Wework.py: Gitee.com(码云) 是 OSCHINA.NET 推出的代码托管平台,支持 Git 和 SVN,提供免费的私有仓库托管。目前已有超过 600 万的开发者选择 Gitee。 # 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 2ce8cc629826cf4bc26dcdc5c70b2047a48980eb (refs/remotes/origin/master)
git config core.sparsecheckout # timeout=10
git checkout -f 2ce8cc629826cf4bc26dcdc5c70b2047a48980eb # timeout=10
Commit message: “update README.md.”
First time build. Skipping changelog.
Injecting SonarQube environment variables using the configuration: sonar
Unpacking https://repo1.maven.org/maven2/org/sonarsource/scanner/cli/sonar-scanner-cli/4.6.1.2450/sonar-scanner-cli-4.6.1.2450.zip to /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonar on Jenkins
[sonar] $ /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonar/bin/sonar-scanner scan -Dsonar.host.url=http://192.168.122.138:9999/ ******** -Dsonar.projectKey=****** -Dsonar.projectBaseDir=/var/jenkins_home/workspace/sonar
INFO: Scanner configuration file: /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonar/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 4.6.1.2450
INFO: Java 1.8.0_221 Oracle Corporation (64-bit)
INFO: Linux 3.10.0-1160.21.1.el7.x86_64 amd64
INFO: User cache: /var/jenkins_home/.sonar/cache
INFO: Scanner configuration file: /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonar/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: Analyzing on SonarQube server 8.9.0
INFO: Default locale: “en”, source code encoding: “UTF-8” (analysis is platform dependent)
WARN: SonarScanner will require Java 11 to run, starting in SonarQube 9.x
INFO: Load global settings
INFO: Load global settings (done) | time=236ms
INFO: Server id: A3D8E380-AXnMPMOl-aneGmECDVqM
INFO: User cache: /var/jenkins_home/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=98ms
INFO: Load/download plugins (done) | time=1833ms
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 18.780s
INFO: Final Memory: 5M/29M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Fail to request url: http://192.168.122.138:9999/api/plugins/download?plugin=kotlin&acceptCompressions=pack200
at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:205)
at org.sonarqube.ws.client.HttpConnector.get(HttpConnector.java:124)
at org.sonarqube.ws.client.HttpConnector.call(HttpConnector.java:111)
at org.sonar.scanner.bootstrap.DefaultScannerWsClient.call(DefaultScannerWsClient.java:73)
at org.sonar.scanner.bootstrap.PluginFiles.download(PluginFiles.java:107)
at org.sonar.scanner.bootstrap.PluginFiles.get(PluginFiles.java:89)
at org.sonar.scanner.bootstrap.ScannerPluginInstaller.loadPlugins(ScannerPluginInstaller.java:77)
at org.sonar.scanner.bootstrap.ScannerPluginInstaller.installRemotes(ScannerPluginInstaller.java:60)
at org.sonar.scanner.bootstrap.ScannerPluginRepository.start(ScannerPluginRepository.java:62)
at org.sonar.core.platform.StartableCloseableSafeLifecyleStrategy.start(StartableCloseableSafeLifecyleStrategy.java:40)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)
at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
at org.picocontainer.behaviors.Stored.start(Stored.java:110)
at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016)
at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009)
at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.io.IOException: unexpected end of stream on http://192.168.122.138:9999/
at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:202)
at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:106)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:79)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at org.sonarqube.ws.client.OkHttpClientBuilder.addHeaders(OkHttpClientBuilder.java:222)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:203)
… 32 more
Suppressed: java.io.IOException: unexpected end of stream on http://192.168.122.138:9999/
… 49 more
Caused by: java.io.EOFException: \n not found: limit=0 content=…
at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:332)
at okhttp3.internal.http1.HeadersReader.readLine(HeadersReader.kt:29)
at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:178)
… 48 more
Caused by: java.io.EOFException: \n not found: limit=0 content=…
at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:332)
at okhttp3.internal.http1.HeadersReader.readLine(HeadersReader.kt:29)
at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:178)
… 48 more
ERROR:
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?
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

image
看起来是这个地址或者接口无法访问,建议确认一下是否启动成功了?

这个地址我没见过,是下载一个插件?我配置里没有这个


你的sonarqube servers怎么配置的?

我重新启动了sonar,日志报这个地址:ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Fail to request url: http://192.168.122.138:9999/api/ce/submit?projectKey=******
配置是这个


key是这个

d2bfca04db8b8a0ffbe32abbe640e7413c2d6fb2

你的jenkins是怎么启动的?看意思是没办法访问到你写的这个sonar地址
建议到jenkins的环境里ping一下这个地址看看通不通

关闭