简体   繁体   English

Jenkins对Java模块的SonarQube分析失败

[英]SonarQube analysis of Java module fails in Jenkins

I have created a Jenkins project to run SonarQube analysis of my product code. 我创建了一个Jenkins项目,以对我的产品代码进行SonarQube分析。 The workspace contains multiple modules (some in Nodejs ie Javascript) and some in Java. 工作区包含多个模块(有些使用Nodejs,即Javascript),有些使用Java。 My sonar properties looks like 我的声纳属性看起来像

sonar.projectKey=product-key
sonar.projectName=product-name
sonar.projectVersion=1.0
sonar.sources=./nodejsmodule1,./nodejsmodule2
sonar.sourceEncoding=UTF-8

This works perfectly without issue and gives me a nice SonarQube dashboard. 这完美地工作了,并且给了我一个不错的SonarQube仪表板。 However, if I change the sonar.sources property to: 但是,如果我将sonar.sources属性更改为:

sonar.sources=./nodejsmodule1,./nodejsmodule2,./java-module-name/src/main/java

the Jenkins build fails with the following error: 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: java.lang.NoSuchMethodError: org.sonar.api.resources.Project.getPom()Lorg/apache/maven/project/MavenProject;
at org.sonar.plugins.surefire.api.SurefireUtils.getReportsDirectoryFromPluginConfiguration(SurefireUtils.java:56)
at org.sonar.plugins.surefire.api.SurefireUtils.getReportsDirectory(SurefireUtils.java:39)
at org.sonar.plugins.surefire.SurefireSensor.analyse(SurefireSensor.java:63)
at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58)
at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50)
at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:98)
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:100)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:85)
at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:258)
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:253)
at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:243)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:100)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:85)
at org.sonar.batch.bootstrap.GlobalContainer.executeAnalysis(GlobalContainer.java:153)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:110)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:76)
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
... 9 more

When I use 当我使用

sonar.sources=./nodejsmodule1,./nodejsmodule2,./java-module-name/pom.xml

The error goes away. 错误消失了。 The multi-language analysis happens. 进行多语言分析。 The events widget on the SonarQube dashboard for the project shows that Java and JavaScript profiles got used during the analysis. 该项目在SonarQube仪表板上的事件小部件显示在分析期间使用了Java和JavaScript配置文件。 But the code analysis results don't contain anything about Java. 但是代码分析结果不包含任何有关Java的内容。 JavaScript analysis results show up. JavaScript分析结果显示出来。 Doesn't matter in which order I specify the sonar.sources values (ie JavaScript followed by Java or Java followed by JavaScript). 我指定sonar.sources值的顺序sonar.sources (即JavaScript后跟Java或Java后跟JavaScript)。 I looked at other StackOverflow questions (eg Sonar analysing Maven 3 and multi language project using JENKINS ). 我看了其他StackOverflow问题(例如Sonar使用JENKINS分析Maven 3和多语言项目 )。 Clearly, they are specifying the location of the classes file as well. 显然,他们也指定了类文件的位置。 Maybe the java code is getting compiled during the Jenkins build step for SonarQube analysis so they can point to the target/classes location. 也许在Jenkins构建步骤中对Java代码进行了编译以进行SonarQube分析,以便它们可以指向target/classes位置。 When I try this (ie sonar.binaries=./java-module-name/target/classes ), the build fails. 当我尝试这个(即sonar.binaries=./java-module-name/target/classes )时,构建失败。

Based on http://docs.sonarqube.org/display/SONAR/Analyzing+with+SonarQube+Scanner+for+Maven#AnalyzingwithSonarQubeScannerforMaven-AnalyzingaMulti-languageProject , I also tried sonar.sources=./java-module-name/src,./java-module-name/pom.xml . 基于http://docs.sonarqube.org/display/SONAR/Analyzing+with+SonarQube+Scanner+for+Maven#AnalyzingwithSonarQubeScannerforMaven-AnalyzingaMulti-languageProject ,我还尝试了sonar.sources=./java-module-name/src,./java-module-name/pom.xml But that brings back the exception. 但这又带来了例外。 The exception also happens for sonar.sources=./java-module-name,./java-module-name/pom.xml , sonar.sources=./java-module-name/src/main,./java-module-name/pom.xml and sonar.sources=./java-module-name/src/main/java,./java-module-name/pom.xml . sonar.sources=./java-module-name,./java-module-name/pom.xml也会发生例外, sonar.sources=./java-module-name/src/main,./java-module-name/pom.xmlsonar.sources=./java-module-name/src/main/java,./java-module-name/pom.xml

What am I doing wrong? 我究竟做错了什么?

The error only shows up when you include Java sources? 仅当包含Java源代码时才会显示该错误? So maybe you are using some outdated plugins on your 5.2, which are triggered on Java analysis and use the no longer available getPom() method. 因此,也许您在5.2上使用了一些过时的插件,这些插件在Java分析中触发并且使用了不再可用的getPom()方法。

org.sonar.api.resources.Project.getPom() is no longer available in SQ 5.2. org.sonar.api.resources.Project.getPom()在SQ 5.2中不再可用。

See Project.class in 5.2 参见5.2中的Project.class

The stacktrace points to surefire. stacktrace指向surefire。 Which version are you using? 您正在使用哪个版本?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SonarQube 6.0 分析在没有代码的模块上失败 - SonarQube 6.0 analysis fails on module without code Jenkins管道出口代码137:在声纳分析中,Maven构建失败 - Jenkins pipeline exit code 137: maven build fails at sonarqube analysis 基于 jenkins 构建失败,原因是声纳分析失败 - Build on jenkins failed couse sonarqube analysis failed Jenkins - Maven Project - SonarQube Analysis is UNSTABLE - ERROR: Unable to create symbol table for - java.lang.IllegalArgumentException: null - Jenkins - Maven Project - SonarQube Analysis is UNSTABLE - ERROR: Unable to create symbol table for - java.lang.IllegalArgumentException: null SonarQube 5.2 升级后,java 分析失败,出现 java.lang.IllegalArgumentException: 没有在线变更集 - After SonarQube 5.2 upgrade java analysis fails with java.lang.IllegalArgumentException: There's no changeset on line 仅在SonarQube服务器在线时才在Jenkins上执行SonarQube分析 - Perform SonarQube analysis on Jenkins only if SonarQube server is online Jenkins slave 静态分析失败 - Static analysis on Jenkins slave fails 如何跳过gradle模块的sonarqube分析 - How to skip sonarqube analysis of gradle module SonarQube Analysis失败,尽管从远程服务器成功检索问题 - SonarQube Analysis fails although retrieval of issues from remote server succeeds SonarQube分析失败java.lang.OutOfMemoryError:Java堆空间 - SonarQube analysis failed java.lang.OutOfMemoryError: Java heap space
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM