ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging。
问题:sonar 插件不能获取。
--------------------------------------------------------------------------------------------------------------------------------------------
官方地址:https://docs.sonarqube.org/display/SCAN/Analyzing+Source+Code
First, you should install the plugin(s) for the language(s) of the project to be analyzed, either by a direct download or through the Marketplace.
Then, you need to choose an analysis method. The following are available:
Note that we do not recommend running an antivirus scanner on the machine where a SonarQube analysis runs, it could result in unpredictable behavior.
可见sonar-scanner 可以是ant,msbuild,maven,gradle,jenkins拉起来;以及自己单独拉起来。
------------------------------------------------------------------------------------------------------------------------------------------
IOS 系统是基于Unix 内核的,所以可以通过ssh连接,通过shell 单独运行 sonar-scanner sh启动文件,查看报错:
bogon:bin suning$ sh sonar-runner
WARN: sonar-runner script is deprecated. Please use sonar-scanner instead.
Unable to find a $JAVA_HOME at "/usr", continuing with system-provided Java...
INFO: Scanner configuration file: /Users/suning/jenkinssonar/sonar-scanner-2.9.0.670/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 2.9.0.670
INFO: Java 1.8.0_74 Oracle Corporation (64-bit)
INFO: Mac OS X 10.12 x86_64
INFO: User cache: /Users/suning/.sonar/cache
ERROR: SonarQube server [http://localhost:9000] can not be reached
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 0.275s
INFO: Final Memory: 3M/123M
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:74)
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.Jars.getBootstrapIndex(Jars.java:100)
at org.sonarsource.scanner.api.internal.Jars.getScannerEngineFiles(Jars.java:76)
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: Failed to connect to localhost/0:0:0:0:0:0:0:1:9000
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connectSocket(RealConnection.java:222)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connect(RealConnection.java:146)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:186)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:121)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.StreamAllocation.newStream(StreamAllocation.java:100)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
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:92)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.getResponseWithInterceptorChain(RealCall.java:179)
at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.execute(RealCall.java:63)
at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:113)
at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:98)
at org.sonarsource.scanner.api.internal.Jars.getBootstrapIndex(Jars.java:96)
... 12 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.Platform.connectSocket(Platform.java:124)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connectSocket(RealConnection.java:220)
... 32 more
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
报错信息和jenkins上报错信息一致!!!
使用debug 调试:
bogon:bin suning$ sh sonar-runner -X
但是 默认地址是localhost
所以在sonar-scanner.properties 中配置地址和属性 如下:
#Configure here general information about the environment, such as SonarQube DB details for example
#No information about specific project should appear here
#----- Default SonarQube server
sonar.host.url=http://10.27.199.187:9000/sonar
sonar.jdbc.url=jdbc:mysql://10.37.87.250:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
sonar.jdbc.username=fabu
sonar.jdbc.password=SuningRds@123
#----- Default source code encoding
sonar.sourceEncoding=UTF-8
sonar.login=admin
sonar.password=admin
调试日志:
bogon:bin suning$ sh sonar-runner -X
WARN: sonar-runner script is deprecated. Please use sonar-scanner instead.
Unable to find a $JAVA_HOME at "/usr", continuing with system-provided Java...
21:23:30.526 INFO: Scanner configuration file: /Users/suning/jenkinssonar/sonar-scanner-2.9.0.670/conf/sonar-scanner.properties
21:23:30.528 INFO: Project root configuration file: NONE
21:23:30.548 INFO: SonarQube Scanner 2.9.0.670
21:23:30.548 INFO: Java 1.8.0_74 Oracle Corporation (64-bit)
21:23:30.549 INFO: Mac OS X 10.12 x86_64
21:23:30.722 DEBUG: keyStore is :
21:23:30.722 DEBUG: keyStore type is : jks
21:23:30.722 DEBUG: keyStore provider is :
21:23:30.722 DEBUG: init keystore
21:23:30.723 DEBUG: init keymanager of type SunX509
21:23:30.758 INFO: User cache: /Users/suning/.sonar/cache
21:23:30.758 DEBUG: Extract sonar-scanner-api-batch in temp...
21:23:30.767 DEBUG: Get bootstrap index...
21:23:30.768 DEBUG: Download: http://10.27.199.187:9000/sonar/batch/index
21:23:35.832 ERROR: SonarQube server [http://10.27.199.187:9000/sonar] can not be reached
21:23:35.832 INFO: ------------------------------------------------------------------------
21:23:35.832 INFO: EXECUTION FAILURE
21:23:35.832 INFO: ------------------------------------------------------------------------
21:23:35.833 INFO: Total time: 5.327s
21:23:35.852 INFO: Final Memory: 3M/123M
21:23:35.853 INFO: ------------------------------------------------------------------------
21:23:35.853 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:74)
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.Jars.getBootstrapIndex(Jars.java:100)
at org.sonarsource.scanner.api.internal.Jars.getScannerEngineFiles(Jars.java:76)
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.SocketTimeoutException: connect timed out
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.Platform.connectSocket(Platform.java:124)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connectSocket(RealConnection.java:220)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connect(RealConnection.java:146)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:186)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:121)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.StreamAllocation.newStream(StreamAllocation.java:100)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
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:92)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.getResponseWithInterceptorChain(RealCall.java:179)
at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.execute(RealCall.java:63)
at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:113)
at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:98)
at org.sonarsource.scanner.api.internal.Jars.getBootstrapIndex(Jars.java:96)
... 12 more
在windos 机器上调试:(sonar-scanner 支持Linux、Unix、window(ios内核是Unix),因为启动文件有bat和sh脚本文件)
2017-12-02 15:36:41
D:\sonar-scanner-2.9.0.670\bin>sonar-scanner.bat -X
D:\sonar-scanner-2.9.0.670\bin\..
21:44:22.317 INFO: Scanner configuration file: D:\sonar-scanner-2.9.0.670\bin\..
\conf\sonar-scanner.properties
21:44:22.358 INFO: Project root configuration file: NONE
21:44:22.490 INFO: SonarQube Scanner 2.9.0.670
21:44:22.492 INFO: Java 1.8.0_101 Oracle Corporation (64-bit)
21:44:22.494 INFO: Windows 7 6.1 amd64
21:44:23.082 DEBUG: keyStore is :
21:44:23.084 DEBUG: keyStore type is : jks
21:44:23.086 DEBUG: keyStore provider is :
21:44:23.087 DEBUG: init keystore
21:44:23.090 DEBUG: init keymanager of type SunX509
21:44:23.514 INFO: User cache: C:\Users\10111065\.sonar\cache
21:44:23.518 DEBUG: Extract sonar-scanner-api-batch in temp...
21:44:23.540 DEBUG: Get bootstrap index...
21:44:23.541 DEBUG: Download: http://10.27.199.187:9000/sonar/batch/index
21:44:23.728 ERROR: SonarQube server [http://10.27.199.187:9000/sonar] can not b
e reached
21:44:23.732 INFO: -------------------------------------------------------------
-----------
21:44:23.734 INFO: EXECUTION FAILURE
21:44:23.736 INFO: -------------------------------------------------------------
-----------
21:44:23.740 INFO: Total time: 1.657s
21:44:23.784 INFO: Final Memory: 4M/61M
21:44:23.787 INFO: -------------------------------------------------------------
-----------
21:44:23.789 ERROR: Error during SonarQube Scanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQu
be
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(Is
olatedLauncherFactory.java:84)
at org.sonarsource.scanner.api.interna
l.IsolatedLauncherFactory$1.run(Is
olatedLauncherFactory.java:71)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLa
uncher(IsolatedLauncherFactory.java:71)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLa
uncher(IsolatedLauncherFactory.java:67)
at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.j
ava:218)
at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.jav
a:156)
at org.sonarsource.scanner.cli.Main.execute(Main.java:74)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from ser
ver
at org.sonarsource.scanner.api.internal.Jars.getBootstrapIndex(Jars.java
:100)
at org.sonarsource.scanner.api.internal.Jars.getScannerEngineFiles(Jars.
java:76)
at org.sonarsource.scanner.api.internal.Jars.download(Jars.java:70)
at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownlo
ader.java:39)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(Is
olatedLauncherFactory.java:75)
... 8 more
Caused by: java.lang.IllegalStateException: Status returned by url [http://10.27
.199.187:9000/sonar/batch/index] is not valid: [404]
at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerC
onnection.java:115)
at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(
ServerConnection.java:98)
at org.sonarsource.scanner.api.internal.Jars.getBootstrapIndex(Jars.java
:96)
... 12 more
所以单独运行sonar-scanner 文件都是这样的调试结果,所以ios运行报错,和sonar-scanner 请求batch/index 异常无关。
#################################################################################
上面报错是使用sonar-scanner2.9.0.670版本,然后换成sonar-scanner2.8 版本就可以了;所以ios平台 : MAC OS X 10.12
INFO: Java 1.8.0_74 Oracle Corporation (64-bit) INFO: Mac OS X 10.12 x86_64只支持sonar-scanner 2.8 !!!