sonarqube集成至jenkins中踩到的坑:java.lang.IllegalStateException: Status returned by url [http://xx.xx.xx...

记录一下自己在集成sonarqube到jenkins中踩到的坑,还是怪自己粗心,记录一下避免以后再次出现同样的问题:

1.注意版本匹配的问题,开始在配置sonarqube的时候,出现过mysqldb死活连接不上的问题,最后发现是mysql的安装版本不对,因此小伙伴们尽量避免采用yum自动化安装的方式,因为这样存在一定的不可控性,最后采用yum localinstall的方法来安装。

目前我安装的各种服务版本为:

sonarqube7.1+jdk1.8+mysql5.7+sonar-scanner3.0

2.sonar-runner和sonnar-scanner是一个东西,旧版叫runner,现在新版叫scanner,这俩装一个就行了,我蠢死了一开始两个都装了,导致环境变量重复了。

3.如果在jenkins中不容易定位集成故障的位置,可以先尝试在sonarqube服务器端用命令行来执行一下扫描任务,看能否扫描成功,排查问题是处在sonar安装上,还是jenkins的集成配置上:

使用-Dproject.settings指定配置文件

/usr/local/sonar-scanner/bin/sonar-scanner -Dproject.settings=/usr/local/sonar-scanner/conf/sonar-scanner.test

4.本人在这个获取不到版本号、Status returned by url [http://xx.xx.xx.xx:9000/batch/index] is not valid的问题上卡了4天,最后发现是自己在jenkins上配置sonarqube server的URL配置不对,蠢死了。

最开始跟着博客无脑填,SonarQube servers中填了服务器ip,报错如下:

org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQubeat 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 serverat 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 moreCaused by: java.lang.IllegalStateException: Status returned by url [http://xx.xx.xx.xx:9000/batch/index] is not valid: [404]at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.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 moreERROR: SonarQube scanner exited with non-zero code: 1

应改为xx.xx.xx.xx:9000/sonar,改完之后就集成运行成功了。

url的具体配置要与sonar-scanner中保持一致,注意不要忘记context中的后缀。

各位小伙伴加油~

你可能感兴趣的:(sonarqube集成至jenkins中踩到的坑:java.lang.IllegalStateException: Status returned by url [http://xx.xx.xx...)