启动svn blame时SonarQube出错

时间:2015-02-26 11:06:42

标签: maven svn sonarqube sonarqube-5.0 sonarqube5.1

我最近将SonarQube服务器从4.5.2升级到5.0.1,再升级到5.1(见下面的编辑)。

突然间,对多模块Maven项目的分析失败,出现以下错误:

[INFO] [12:02:05.045] Sensor SCM Sensor...
[INFO] [12:02:05.169] SCM provider for this project is: svn
[INFO] [12:02:05.169] Retrieve SCM blame information...
[INFO] [12:02:05.185] 650 files to be analyzed
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] myproject ......................................... FAILURE [3:21.165s]
[INFO] module1 ........................................... SKIPPED
[INFO] module2 ........................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:42.429s
[INFO] Finished at: Thu Feb 26 11:30:01 CET 2015
[INFO] Final Memory: 73M/2020M
[DEBUG] [11:30:01.789] Executing: svn blame --xml --non-interactive -x -w src/main/java/MyClass.java
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar (default-cli) on project myproject: java.io.IOException: Cannot run progra
m "svn" (in directory "C:\somedirectory\module1"): CreateProcess error=2, The system cannot find the file specified
        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:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
        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.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: java.io.IOException: Cannot run program "svn" (in directory "C:\somedirectory\module1"): CreateProcess error=2, The system cannot find the file specified
        at org.codehaus.mojo.sonar.bootstrap.ExceptionHandling.handle(ExceptionHandling.java:41)
        at org.codehaus.mojo.sonar.bootstrap.RunnerBootstraper.execute(RunnerBootstraper.java:139)
        at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:138)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 19 more

不知何故,命令svn在目录src/main/java/MyClass.java中找不到文件C:\somedirectory\module1,尽管该文件肯定存在。如果我复制粘贴命令SonarQube试图在目录svn blame --xml --non-interactive -x -w src/main/java/MyClass.java内的命令提示符C:\somedirectory\module1中执行,那么该命令正常工作。

svn命令在PATH上是正确的,如在"库路径"中可以看到的那样。字段"系统信息" SonarQube服务器中的页面。 SonarQube服务器托管在执行mvn sonar:sonar的同一台服务器上(Windows Server 2008 R2)。

SonarQube正在发起

svn来检索责备历史。据我了解,there were some changes made in SonarQube 5.0 concerning SCM support(更改为内置)。我现在的解决方法是在SonarQube中禁用SCM传感器(使用-Dsonar.scm.disabled=true或直接在SonarQube服务器中,在"设置>常规设置> SCM")下。

这与this question无关,因为我在升级到SonarQube 5.0.1时只遇到了这种行为。

使用的JRE:1.7.0_51(64位)

编辑:

升级到SonarQube 5.1后,错误仍然存​​在,但消息不同且更清晰。我重新安装了SVN客户端(TortoiseSVN)并重新启动了Jenkins和SonarQube,但错误仍然存​​在:

  

SCM提供商被设置为" svn"但没有为此密钥找到SCM提供商。没有安装SCM提供程序

[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar (default-cli) on project bombardier: SCM provider was set to "svn" but no SCM provider found for this key. No SCM provider installed -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar (default-cli) on project bombardier: SCM provider was set to "svn" but no SCM provider found for this key. No SCM provider installed
    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:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    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.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: SCM provider was set to "svn" but no SCM provider found for this key. No SCM provider installed
    at org.codehaus.mojo.sonar.bootstrap.ExceptionHandling.handle(ExceptionHandling.java:41)
    at org.codehaus.mojo.sonar.bootstrap.RunnerBootstraper.execute(RunnerBootstraper.java:139)
    at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:138)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
Caused by: java.lang.IllegalArgumentException: SCM provider was set to "svn" but no SCM provider found for this key. No SCM provider installed
    at org.sonar.batch.scm.ScmConfiguration.setProviderIfSupported(ScmConfiguration.java:123)
    at org.sonar.batch.scm.ScmConfiguration.considerOldScmUrl(ScmConfiguration.java:133)
    at org.sonar.batch.scm.ScmConfiguration.start(ScmConfiguration.java:109)
    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.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110)
    at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89)
    at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)
    at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
    at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
    at org.picocontainer.behaviors.Stored.start(Stored.java:110)
    at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1015)
    at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1008)
    at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:766)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:91)
    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$1.delegateExecution(BatchLauncher.java:87)
    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.codehaus.mojo.sonar.bootstrap.RunnerBootstraper.execute(RunnerBootstraper.java:135)
    ... 22 more

6 个答案:

答案 0 :(得分:37)

使用以下命令将禁用与svn相关的问题

-Dsonar.scm.disabled=True

这将禁用svn

答案 1 :(得分:8)

安装SonarQube 5.1后遇到同样的问题,请转到更新中心

  

http://your_domain:port/updatecenter/available

搜索“SVN”,点击“安装”

  

https://docs.sonarqube.org/display/PLUG/SVN+Plugin

会出现这样的事情:

  

需要重新启动SonarQube才能安装以下内容   插件:sonar-scm-svn-plugin-1.0.jar

重新启动SonarQube。

答案 2 :(得分:7)

这个问题可以通过两种方式解决,
1.通过设置sonar.properties -Dsonar.scm.disabled = True,这仅适用于sonarrunner.bat声纳分析,
2.如果您使用任何其他类型分析,然后使用admin默认管理员登录为admin / admin(用户名/密码)。http://yourDomin:port/settings/index(e.g http://localhost:9000/settings/index)然后在类别中选择scm并禁用scm传感器设置为真的。
3.或者你可以在登录后以管理员(admin / admin)的身份将svn插件添加到声纳http://your_domain:port/updatecenter/available,搜索可用的插件并选择svn并安装它..

答案 3 :(得分:1)

我遇到了这个问题,这是因为没有在运行声纳分析的构建机器上主动安装SVN。声纳盒安装的并不重要。这是需要做SVN责任的构建代理。

我在使用CentOS。神奇的是

sudo yum install svn

最后一招是确保构建机器使用相同版本的SVN进行结帐,就像我安装的版本一样。如果构建机器本身使用不同的版本,您可能必须确保它在下次检出之前清理整个工作区。

最后,不要忘记Sonar也需要您的SVN凭证!

答案 4 :(得分:0)

请检查SonarQube进程是否具有与用于测试的环境变量相同的颜色。

答案 5 :(得分:0)

我刚刚在Redhat Linux机器上安装了SonarQube 5.0.1,我遇到了完全相同的问题。

我没有禁用scm stats插件,而是安装了一个svn客户端(svnkit.x86_64),并且在激活SCM的情况下成功执行了构建。 所以我想在Windows上,你应该安装一个svn客户端并把它放在PATH上。