Sonar从4.5版升级到5.1.1版之后,很多工作现在都失败了。但有些项目已成功分析。
问题似乎与这些帖子相同:SonarQube "Insufficient privileges"& Insufficient privileges error with sonarRunner
但这不是凭据错误,因为我的一些项目已成功分析。
出现问题时,我在Jenkins方面(Sonar跑步者日志)收到此消息:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:26.443s
[INFO] Finished at: Fri Aug 07 10:35:46 CEST 2015
[INFO] Final Memory: 54M/765M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project XXXX: Fail to decorate 'org.sonar.api.resources.File@23e88d14[key=src/main/webapp/js/XXXXXXX/XXXXjs,path=src/main/webapp/js/XXXX/XXXX/XXXX.js,filename=XXXXX.js,language=JavaScript]': Insufficient privileges -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project Opale: Fail to decorate 'org.sonar.api.resources.File@23e88d14[key=src/main/webapp/js/XXXX/XXXXX/XXXXX.js,path=src/main/webapp/js/XXXX/XXXX/XXXX.js,filename=XXXX.js,language=JavaScript]'
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
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:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
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:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Fail to decorate 'org.sonar.api.resources.File@23e88d14[key=src/main/webapp/js/etiquetage/compositionTsf/DetailCompositionTsfController.js,path=src/main/webapp/js/etiquetage/compositionTsf/DetailCompositionTsfController.js,filename=DetailCompositionTsfController.js,language=JavaScript]'
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:132)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: org.sonar.api.utils.SonarException: Fail to decorate 'org.sonar.api.resources.File@23e88d14[key=src/main/webapp/js/etiquetage/compositionTsf/DetailCompositionTsfController.js,path=src/main/webapp/js/etiquetage/compositionTsf/DetailCompositionTsfController.js,filename=DetailCompositionTsfController.js,language=JavaScript]'
at org.sonar.batch.phases.DecoratorsExecutor.executeDecorator(DecoratorsExecutor.java:104)
at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:87)
at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:79)
at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:79)
at org.sonar.batch.phases.DecoratorsExecutor.execute(DecoratorsExecutor.java:71)
at org.sonar.batch.phases.DatabaseModePhaseExecutor.execute(DatabaseModePhaseExecutor.java:127)
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:264)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:235)
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:230)
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:228)
at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:220)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
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:601)
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
Caused by: java.lang.IllegalStateException: Insufficient privileges
at org.sonar.batch.bootstrap.ServerClient.handleHttpException(ServerClient.java:137)
at org.sonar.batch.bootstrap.ServerClient.request(ServerClient.java:107)
at org.sonar.batch.bootstrap.ServerClient.request(ServerClient.java:99)
at org.sonar.batch.bootstrap.ServerClient.request(ServerClient.java:87)
at org.sonar.batch.issue.tracking.DefaultServerLineHashesLoader.loadHashesFromWs(DefaultServerLineHashesLoader.java:47)
at org.sonar.batch.issue.tracking.DefaultServerLineHashesLoader.getLineHashes(DefaultServerLineHashesLoader.java:38)
at org.sonar.batch.issue.tracking.SourceHashHolder.initHashes(SourceHashHolder.java:52)
at org.sonar.batch.issue.tracking.SourceHashHolder.getHashedSource(SourceHashHolder.java:65)
at org.sonar.batch.issue.tracking.IssueTracking.setChecksumOnNewIssues(IssueTracking.java:66)
at org.sonar.batch.issue.tracking.IssueTracking.track(IssueTracking.java:51)
at org.sonar.batch.issue.tracking.IssueTrackingDecorator.doDecorate(IssueTrackingDecorator.java:139)
at org.sonar.batch.issue.tracking.IssueTrackingDecorator.decorate(IssueTrackingDecorator.java:113)
at org.sonar.batch.phases.DecoratorsExecutor.executeDecorator(DecoratorsExecutor.java:96)
... 57 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
Sonar analysis completed: FAILURE
Build step 'Sonar' changed build result to FAILURE
Build step 'Sonar' marked build as failure
当我检查SonarQube的访问日志时,我发现:
127.0.0.1 - - [07/Aug/2015:03:38:14 +0200] "GET /sonar/api/sources/hash?key=XXX.YYY%3AZZZZZ%3Asrc%2Fmain%2Fwebapp%2Fjs%2FXXXX%2FXXXX%2FXXXXXX.js HTTP/1.0" 403 46 "-" "SonarQube Maven/3.0.5"
我们看到服务器返回403错误。然后,sonarrunner在其日志中打印出身份验证问题是正常的。
但是,当我将源代码与成功构建的项目进行比较时,我发现它们包含没有重音字符的UTF-8源代码。
然后我将重音字符添加到源文件中,分析失败。
我怀疑源文件上包含重音符号的哈希方法存在问题。
答案 0 :(得分:0)
403错误是授权错误。
此WS返回所请求文件行的哈希值,您需要对文件的源代码权限才能获得响应(即文件所属项目的源代码权限)。文件内容与授权无关。
如果你得到403,你就没有对该文件所属的项目拥有正确的权限。检查配置。
我只能想象在这种情况下可能涉及编码的场景如下: