发布报告时声纳空指针错误
Sonar null pointer error when publishing report
当 运行 在 Jenkins 中进行分析时出现此错误:
22:36:58.682 INFO: ------------------------------------------------------------------------
22:36:58.682 INFO: EXECUTION FAILURE
22:36:58.682 INFO: ------------------------------------------------------------------------
22:36:58.682 INFO: Total time: 2:18.929s
22:36:58.915 INFO: Final Memory: 44M/445M
22:36:58.915 INFO: ------------------------------------------------------------------------
22:36:58.915 ERROR: Error during SonarQube Scanner execution
java.lang.NullPointerException
at org.sonar.scanner.report.ComponentsPublisher.convert(ComponentsPublisher.java:104)
at org.sonar.scanner.report.ComponentsPublisher.publish(ComponentsPublisher.java:69)
at org.sonar.scanner.report.ReportPublisher.generateReportFile(ReportPublisher.java:152)
at org.sonar.scanner.report.ReportPublisher.execute(ReportPublisher.java:138)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:366)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
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:185)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
SonarQube 服务器版本为 7.9.1 版(内部版本 27448)(企业版)。 Jenkins 中的 SonarScanner 是 3.3.0.1492 版本。相关的管道执行参数如下:
withSonarQubeEnv('GDMSonarEnterprise') {
sh "${scannerHome}/bin/sonar-scanner"+
" -X -Dsonar.projectBaseDir="+parent+
" -Dsonar.projectKey="+key_sonar+
" -Dsonar.projectName="+name+
" -Dsonar.branch.name=master"+
" -Dsonar.projectVersion="+currentVersion.format("dd-MM-yyyy-HH:mm", TimeZone.getTimeZone('UTC'))+
" -Dsonar.java.coveragePlugin=jacoco"+
" -Dsonar.scm.disabled=false"+
" -Dsonar.modules="+modules+
" -Dsonar.verbose=true"+
" -Dsonar.login=somelogin"+
" -Dsonar.password=somepassword"+
" -Dsonar.svn.username=somelogin"+
" -Dsonar.svn.password.secured=somepassword"+
" -Dsonar.sources=src/main"+
" -Dsonar.exclusions=**/*.scss,**/*.xml,**/*.php,**/*.js,**/*.css,**/*.jsv,**/*.html,**/*.zul,**/Q*.java,**/*Test.java,**/*Test*.java,**/*.xsd,**/*.sql"+
" -Dsonar.lang.patterns.tsql=**/*.tsql"+
" -Dsonar.java.binaries=target"+
" -Dsonar.tests=src/test"
}
}
我试过使用和不使用 -Dsonar.login 和 -Dsonar.password 参数,因为我有一个服务器令牌(在另一个 Jenkins 作业中,整个操作进行得很顺利)。
查看错误日志,似乎处于执行的发布阶段。作为记录,之前的 Maven 构建阶段正确执行。
感谢任何帮助,如果需要更多信息,我会尽力提供。
干杯。
检查 token/user 在项目设置 -> 权限中是否具有“执行分析”权限。
我遇到了同样的异常,并在尝试切换到 sonar-scanner 命令后最终发现问题所在,该命令实际上提供了一条有用的错误消息。
当 运行 在 Jenkins 中进行分析时出现此错误:
22:36:58.682 INFO: ------------------------------------------------------------------------
22:36:58.682 INFO: EXECUTION FAILURE
22:36:58.682 INFO: ------------------------------------------------------------------------
22:36:58.682 INFO: Total time: 2:18.929s
22:36:58.915 INFO: Final Memory: 44M/445M
22:36:58.915 INFO: ------------------------------------------------------------------------
22:36:58.915 ERROR: Error during SonarQube Scanner execution
java.lang.NullPointerException
at org.sonar.scanner.report.ComponentsPublisher.convert(ComponentsPublisher.java:104)
at org.sonar.scanner.report.ComponentsPublisher.publish(ComponentsPublisher.java:69)
at org.sonar.scanner.report.ReportPublisher.generateReportFile(ReportPublisher.java:152)
at org.sonar.scanner.report.ReportPublisher.execute(ReportPublisher.java:138)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:366)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
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:185)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
SonarQube 服务器版本为 7.9.1 版(内部版本 27448)(企业版)。 Jenkins 中的 SonarScanner 是 3.3.0.1492 版本。相关的管道执行参数如下:
withSonarQubeEnv('GDMSonarEnterprise') {
sh "${scannerHome}/bin/sonar-scanner"+
" -X -Dsonar.projectBaseDir="+parent+
" -Dsonar.projectKey="+key_sonar+
" -Dsonar.projectName="+name+
" -Dsonar.branch.name=master"+
" -Dsonar.projectVersion="+currentVersion.format("dd-MM-yyyy-HH:mm", TimeZone.getTimeZone('UTC'))+
" -Dsonar.java.coveragePlugin=jacoco"+
" -Dsonar.scm.disabled=false"+
" -Dsonar.modules="+modules+
" -Dsonar.verbose=true"+
" -Dsonar.login=somelogin"+
" -Dsonar.password=somepassword"+
" -Dsonar.svn.username=somelogin"+
" -Dsonar.svn.password.secured=somepassword"+
" -Dsonar.sources=src/main"+
" -Dsonar.exclusions=**/*.scss,**/*.xml,**/*.php,**/*.js,**/*.css,**/*.jsv,**/*.html,**/*.zul,**/Q*.java,**/*Test.java,**/*Test*.java,**/*.xsd,**/*.sql"+
" -Dsonar.lang.patterns.tsql=**/*.tsql"+
" -Dsonar.java.binaries=target"+
" -Dsonar.tests=src/test"
}
}
我试过使用和不使用 -Dsonar.login 和 -Dsonar.password 参数,因为我有一个服务器令牌(在另一个 Jenkins 作业中,整个操作进行得很顺利)。
查看错误日志,似乎处于执行的发布阶段。作为记录,之前的 Maven 构建阶段正确执行。
感谢任何帮助,如果需要更多信息,我会尽力提供。
干杯。
检查 token/user 在项目设置 -> 权限中是否具有“执行分析”权限。
我遇到了同样的异常,并在尝试切换到 sonar-scanner 命令后最终发现问题所在,该命令实际上提供了一条有用的错误消息。