执行 Sonarqube 分析时出错权限不足" [英] Error while executing Sonarqube analysis " Insufficient privileges"
问题描述
我正在尝试通过 sonarqube 分析 java 代码.我们在本地环境中创建了一个 sonarqube 服务器,而不是使用声纳云.
I am trying to analyse java code through sonarqube. We have created a sonarqube server in our local environment and not using sonar cloud.
我最初尝试使用 sonar maven 插件形成此链接 Sonar-Maven 插件
I tried using sonar maven plugin initially form this link Sonar-Maven Plugin
但是我遇到了权限不足"错误.
However I faced an "Insufficient privileges" error.
[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 进行分析,我再次遇到同样的权限不足"错误.
Then I tried to analyse using Sonar runner and I got same "Insufficient privileges" error again.
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 服务器并重新运行,它运行良好.我试图找出第一台服务器出了什么问题.服务器和项目的配置是一样的.
Then I created a new Sonarqube server and re-ran the execution and it worked fine. I am trying to find out what was going wrong in the first server. The configuration for server and project was same.
提前致谢.
推荐答案
如 this answer 中所述,检查 SonarQube您用于工作的用户权限:
As mentioned in this answer, check the SonarQube user permission that you are using for your job:
全局
:执行分析项目
:浏览并查看源代码
global
: Execute Analysisproject
: BROWSE and SEE SOURCE CODE
这些可能默认在您的新 SonarQube 服务器中.
Those might be by default in your new SonarQube server.
是的,问题是Anyone"组以某种方式被删除,这阻止了代码被推送到 SonarQube.
Yes the problem was "Anyone" group was removed somehow and this prevented code from being pushed to SonarQube.
在 Sonarqube/Security/Authorization/Group 中查看更多信息.
See more at Sonarqube / Security / Authorization / Group.
这篇关于执行 Sonarqube 分析时出错权限不足"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!