在Jenkins上运行sonarqube独立分析时出现以下错误。 sonarqube扫描仪能够识别要分析的文件并能够很好地分析它们,但问题在于它是否试图将项目发布到仪表板。
当我在浏览器中打开网址http://vv123456:9000/api/ce/submit?projectKey=pkey&projectName=pname时,它会显示“{”errors“:[{”msg“:”需要HTTP方法POST}}}}“,其中意味着sonarqube webservice很好。
Jenkins构建错误:
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: org.sonarqube.ws.client.HttpException: Error 500 on [http://vv123456:9000/api/ce/submit?projectKey=pkey&projectName=pname][1]
at org.sonarqube.ws.client.BaseResponse.failIfNotSuccessful(BaseResponse.java:34)
at org.sonar.batch.bootstrap.BatchWsClient.failIfUnauthorized(BatchWsClient.java:99)
at org.sonar.batch.bootstrap.BatchWsClient.call(BatchWsClient.java:69)
at org.sonar.batch.report.ReportPublisher.upload(ReportPublisher.java:172)
at org.sonar.batch.report.ReportPublisher.execute(ReportPublisher.java:127)
at org.sonar.batch.phases.PublishPhaseExecutor.publishReportJob(PublishPhaseExecutor.java:64)
at org.sonar.batch.phases.PublishPhaseExecutor.executeOnRoot(PublishPhaseExecutor.java:51)
at org.sonar.batch.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:86)
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241)
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236)
at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47)
at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:79)
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
... 9 more
答案 0 :(得分:8)
在托管Web服务的服务器上的SonarQube日志中(在我的案例中为vv123456),记录的错误为:
No such file or directory - C:/Windows/system32/config/systemprofile/AppData/Local/Temp
所以,我在wrapper.conf中添加了临时位置的路径:
set.TMPDIR=/SonarQube/sonarqube-5.6/temp
这解决了这个问题。
答案 1 :(得分:6)
我也遇到过这个问题。查看/opt/sonar/logs/sonar.log
的日志,我可以看到以下错误:
Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (9122692 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable.
来自此处的建议https://dev.mysql.com/doc/refman/5.6/en/packet-too-large.html
在这里
PacketTooBigException when running a sonar analysis
在这里
http://codefabulae.blogspot.co.uk/2012/05/sonar-analysis-and-mysql-max-packet.html
最终解决方案是将其写入我的mysql config /etc/my.cnf
:
[mysqld]
max_allowed_packet=32M
重启mysqld
sudo service mysqld restart
并通过
进行检查mysql <insert user credentials here>
mysql> show variables like "max_allowed%";
然后重新启动声纳
sudo service sonar restart
然后我的构建停止了上面提到的500错误。
这是解决PacketTooBig问题的方法,这可能是一个根本原因。
答案 2 :(得分:1)
我找到了解决方案: 用户必须增加Mysql My.config文件的max_allowed_packet大小以及sonar.config中的Mysql连接字符串。
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&max_allowed_packet=512M
答案 3 :(得分:0)
尝试这个程序,它对我有用: