I am trying to analyse java code through sonarqube. We have created a sonarqube server in our local environment and not using sonar cloud.
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.
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
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.
Thanks in advance.
As mentioned in this answer, check the SonarQube user permission that you are using for your job:
global
: Execute Analysisproject
: BROWSE and SEE SOURCE CODEThose might be by default in your new SonarQube server.
As the OP VVP confirms in the comments:
Yes the problem was "Anyone" group was removed somehow and this prevented code from being pushed to SonarQube.
See more at Sonarqube / Security / Authorization / Group.