由于 Sonar 插件导致构建失败

Build failure due to Sonar plugin

由于此错误,我的构建在 Jenkins 上一直失败:

ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
    at org.sonar.runner.impl.BatchLauncher.delegateExecution(BatchLauncher.java:91)
    at org.sonar.runner.impl.BatchLauncher.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.getConfiguration()Lorg/apache/commons/configuration/Configuration;
    at org.sonar.plugins.java.JavaSquidSensor.createConfiguration(JavaSquidSensor.java:106)
    at org.sonar.plugins.java.JavaSquidSensor.analyse(JavaSquidSensor.java:82)
    at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:59)
    at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:51)
    at org.sonar.batch.phases.DatabaseModePhaseExecutor.execute(DatabaseModePhaseExecutor.java:120)
    at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:264)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:235)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:230)
    at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:220)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
    at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
    at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:135)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:158)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
    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.delegateExecution(BatchLauncher.java:87)
    ... 9 more
ERROR: 
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Build step 'Invoke Standalone SonarQube Analysis' marked build as failure
Email was triggered for: Failure - Any
Sending email for trigger: Failure - Any
Sending email to: jreimers@nyiso.com
Finished: FAILURE

我认为这是因为 SonarQube 5.1 不再需要 JavaSquidSensor,所以我删除了它:

以上是我的插件文件夹。我删除了 sonar-squid-java-plugin-2.2.1 但我仍然遇到同样的错误。

关于为什么这种情况仍然发生的任何想法? 运行 Windows-64

上的声纳

您需要将 SonarQube Java 插件更新到更新的版本,您的错误来自已弃用的 API,它已从 SonarQube 5.1 中删除 - 并在更新的版本中修复SonarQube Java(撰写本文时最新版本为 3.3)。