执行Sonarqube分析时出错“权限不足”

时间:2017-09-18 03:15:40

标签: sonarqube sonar-runner sonarqube-scan

我试图通过sonarqube分析java代码。我们在本地环境中创建了一个sonarqube服务器,而不是使用声纳云。

我尝试使用sonar maven插件最初形成此链接Sonar-Maven Plugin

但是我遇到了“权限不足”错误。

[INFO] BUILD FAILURE [INFO]
------------------------------------------------------------------------ [INFO] Total time: 22.185 s [INFO] Finished at: 2017-09-18T13:04:47+10:00 [INFO] Final Memory: 64M/589M [INFO]
------------------------------------------------------------------------ [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:
3.3.0.603:sonar (default-cli) on project testproject: Insufficient privileges ->  [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o rg.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on  project testproject: Insufficient privileges
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor .java:213)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor .java:154)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor .java:146)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje ct(LifecycleModuleBuilder.java:117)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje ct(LifecycleModuleBuilder.java:81)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThre adedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl eStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun cher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav a:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La uncher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java: 356) Caused by: org.apache.maven.plugin.MojoExecutionException: Insufficient privileg es
        at org.sonarsource.scanner.maven.bootstrap.ExceptionHandling.handle(Exce ptionHandling.java:36)
        at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(S cannerBootstrapper.java:80)
        at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.jav a:139)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default BuildPluginManager.java:134)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor .java:208)
        ... 20 more Caused by: Insufficient privileges [ERROR] [ERROR] Re-run Maven using the -X switch to enable full debug logging.

然后我尝试使用Sonar runner进行分析,并且我再次获得了“Insufficient privileges”错误。

13:01:41.145 DEBUG: Upload report
13:01:41.179 DEBUG: POST 403 http://myserver:9000/api/ce/submit?projectKey=
SampleProject&projectName=sampleprojectWrapper | time=34ms
13:01:41.208 INFO: -------------------------------------------------------------
-----------
13:01:41.209 INFO: EXECUTION FAILURE
13:01:41.209 INFO: -------------------------------------------------------------
-----------
13:01:41.211 INFO: Total time: 12.919s
13:01:41.412 INFO: Final Memory: 52M/320M
13:01:41.413 INFO: -------------------------------------------------------------
-----------
13:01:41.414 ERROR: Error during SonarQube Scanner execution
Insufficient privileges

然后我创建了一个新的Sonarqube服务器并重新运行执行,它工作正常。 我试图找出第一台服务器出了什么问题。服务器和项目的配置是相同的。

提前致谢。

2 个答案:

答案 0 :(得分:3)

this answer中所述,请检查您用于工作的SonarQube用户权限:

  • global:执行分析
  • project:浏览并查看源代码

默认情况下,您的新SonarQube服务器可能会出现这些内容。

OP VVP确认in the comments

  

是的问题是" 任何人"以某种方式移除了组,这阻止了代码被推送到SonarQube。

请参阅Sonarqube / Security / Authorization / Group

答案 1 :(得分:2)

了解如何解决此问题的最新消息 我正在使用Sonar runner来分析代码 问题是“任何人”组的权限以某种方式被删除。按照上面的回答,我再次添加了权限,执行了,我可以看到发布的结果。

Sonar Group Configuration