在声纳解决声纳问题后,声纳分析失败

时间:2017-12-29 14:28:11

标签: maven jenkins sonarqube bitbucket

我们在jenkins触发的构建中使用声纳分析,代码驻留在bitbucket中。当PR被提升并且在声纳分析期间没有报告任何问题时,声纳在bitbucket中显示了PR的成功。

但是,如果PR的初始运行面临任何声纳问题,声纳分析会反复失败并出现以下错误。即使在提交代码更改以解决声纳问题之后,也会发生这种情况。除非我们再创建一个新分支并再次提高PR,否则声纳分析不会成功。

以下是构建日志中的例外情况:

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar (default-cli) on project assessment-parent: Unable to load component class org.sonar.batch.scan.ImmutableProjectReactor: Unable to perform Bitbucket WS operation: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar (default-cli) on project assessment-parent:

 - 

    Unable to load component class
       org.sonar.batch.scan.ImmutableProjectReactor     at 

           org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
            at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
            at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
            at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
            at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
            at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
            at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
            at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
            at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
            at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
            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:483)
            at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
            at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
            at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
            at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
           Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to load component class org.sonar.batch.scan.ImmutableProjectReactor
            at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:65)
            at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.java:108)
            at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
            ... 19 more
           Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.batch.scan.ImmutableProjectReactor
            at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:69)
            at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
            at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
            at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
            at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
            at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
            at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
            at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
            at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
            at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
            at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
            at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
            at org.picocontainer.DefaultPicoContainer.instantiateComponentAsIsStartable(DefaultPicoContainer.java:1034)
            at org.picocontainer.DefaultPicoContainer.addAdapterIfStartable(DefaultPicoContainer.java:1026)
            at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1003)
            at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
            at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:141)
            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.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:483)
            at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
            at com.sun.proxy.$Proxy19.execute(Unknown Source)
            at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:171)
            at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128)
            at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:63)
            ... 22 more
           Caused by: java.lang.IllegalStateException: Unable to perform Bitbucket WS operation
            at com.wirelust.sonar.plugins.bitbucket.PullRequestFacade.init(PullRequestFacade.java:152)
            at com.wirelust.sonar.plugins.bitbucket.PullRequestProjectBuilder.build(PullRequestProjectBuilder.java:51)
            at org.sonar.batch.scan.ProjectBuildersExecutor.execute(ProjectBuildersExecutor.java:49)
            at org.sonar.batch.scan.ImmutableProjectReactorProvider.provide(ImmutableProjectReactorProvider.java:32)
            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:483)
            at org.picocontainer.injectors.MethodInjector.invokeMethod(MethodInjector.java:129)
            at org.picocontainer.injectors.MethodInjector.access$000(MethodInjector.java:39)
            at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:113)
            at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
            at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120)
            at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58)
            at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142)
            at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96)
            at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
            at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
            at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:67)
            ... 56 more
           Caused by: java.lang.NullPointerException
            at com.wirelust.sonar.plugins.bitbucket.PullRequestFacade.loadExistingReviewCommentsWithPage(PullRequestFacade.java:229)
            at com.wirelust.sonar.plugins.bitbucket.PullRequestFacade.loadExistingReviewComments(PullRequestFacade.java:216)
            at com.wirelust.sonar.plugins.bitbucket.PullRequestFacade.init(PullRequestFacade.java:148)
            ... 74 more


[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
SonarQube analysis completed: FAILURE
Build step 'SonarQube analysis with Maven' changed build result to FAILURE
Build step 'SonarQube analysis with Maven' marked build as failure
Finished: FAILURE

1 个答案:

答案 0 :(得分:0)

如果您正在使用社区版本的声纳分支插件。您的sonar.branch.target应该是master。

该插件当前在检查分支名称方面没有任何逻辑,因此,如果该项目尚不存在,则指定sonar.branch.name或source.branch.target将导致错误。

在这种情况下,有可能检查sonar.branch.name是否等于master并返回DefaultBranchConfiguration实例,前提是sonar.branch.target也等于master-或者为空或未指定-否则可能存在问题稍后再分支。

我不知道官方版本是如何做到的,因此无法确定我们是否一致,但是文档似乎表明默认分支是作为master创建的,因此这种方法应该一致。

因此,我们将通过以下方式处理“缺失”项目上的输入组合:

input combinations table

有关更多详细信息,您可以检查此链接https://github.com/mc1arke/sonarqube-community-branch-plugin/issues/1