MS build and SonarQube analysis from jenkins, unable to execute Sonar, E170001

喜夏-厌秋 提交于 2020-01-05 04:09:07

问题


I'm trying to build a .Net project and start the sonarqube code analysis with jenkins. I did the following steps:

  1. Download SonarQube
  2. Start the SonarQube server: C:...\sonarqube\bin\windows-x86-64\StartSonar.bat
  3. Install SonarQube 2.4.4 Plugin on Jenkins
  4. Go to http://localhost:8080/configure and configure the SonarQube server as shown here:

  5. Go to http://localhost:8080/configureTools/ and configure SonarQube Scanner for MSBuild like this:

  1. Added a job in jenkins, configured the project to be build with MS build, wrapped the build step with SonarQube Scanner for MSBuild - Begin Analysis and SonarQube Scanner for MSBuild - End Analysis:

My Problem: jenkings checking out the project files and building the project successfully but the analysis fails.

here is the relevant console output:

10:53:36.189 INFO  - 113 files to be analyzed
10:53:36.805 INFO  - 0/113 files analyzed
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 17.443s
Final Memory: 18M/404M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
    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.sonar.runner.Main.executeTask(Main.java:70)
    at org.sonar.runner.Main.execute(Main.java:59)
    at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.IllegalStateException: Error when executing blame for file App_Start/BundleConfig.cs
    at org.sonar.plugins.scm.svn.SvnBlameCommand.blame(SvnBlameCommand.java:102)
    at org.sonar.plugins.scm.svn.SvnBlameCommand.blame(SvnBlameCommand.java:59)
    at org.sonar.batch.scm.ScmSensor.execute(ScmSensor.java:86)
    at org.sonar.batch.sensor.SensorWrapper.analyse(SensorWrapper.java:57)
    at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58)
    at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50)
    at org.sonar.batch.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:83)
    at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
    at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:234)
    at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
    at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47)
    at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
    at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:79)
    at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
    ... 9 more
Caused by: org.tmatesoft.svn.core.SVNAuthenticationException: svn: E170001: Authentication required for '<https://subversion.xyz:443> 
    at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.authenticationFailed(SVNErrorManager.java:47)
    at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.authenticationFailed(SVNErrorManager.java:41)
    at org.tmatesoft.svn.core.internal.wc.DefaultSVNAuthenticationManager.getFirstAuthentication(DefaultSVNAuthenticationManager.java:203)
    at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:716)
    at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:398)
    at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:386)
    at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.performHttpRequest(DAVConnection.java:863)
    at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.exchangeCapabilities(DAVConnection.java:699)
    at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.open(DAVConnection.java:118)
    at org.tmatesoft.svn.core.internal.io.dav.DAVRepository.openConnection(DAVRepository.java:1049)
    at org.tmatesoft.svn.core.internal.io.dav.DAVRepository.hasCapability(DAVRepository.java:877)
    at org.tmatesoft.svn.core.io.SVNRepository.assertServerIsMergeInfoCapable(SVNRepository.java:787)
    at org.tmatesoft.svn.core.io.SVNRepository.getFileRevisions(SVNRepository.java:756)
    at org.tmatesoft.svn.core.internal.wc16.SVNLogClient16.doAnnotate(SVNLogClient16.java:1389)
    at org.tmatesoft.svn.core.internal.wc16.SVNLogClient16.doAnnotate(SVNLogClient16.java:291)
    at org.tmatesoft.svn.core.internal.wc2.old.SvnOldAnnotate.run(SvnOldAnnotate.java:45)
    at org.tmatesoft.svn.core.internal.wc2.old.SvnOldAnnotate.run(SvnOldAnnotate.java:17)
    at org.tmatesoft.svn.core.internal.wc2.SvnOperationRunner.run(SvnOperationRunner.java:21)
    at org.tmatesoft.svn.core.wc2.SvnOperationFactory.run(SvnOperationFactory.java:1235)
    at org.tmatesoft.svn.core.wc2.SvnOperation.run(SvnOperation.java:294)
    at org.tmatesoft.svn.core.wc.SVNLogClient.doAnnotate(SVNLogClient.java:295)
    at org.sonar.plugins.scm.svn.SvnBlameCommand.blame(SvnBlameCommand.java:100)
    ... 37 more
ERROR: 
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
The SonarQube Scanner did not complete successfully
10:53:37.058  Creating a summary markdown file...
Post-processing failed. Exit code: 1
ERROR: Execution of SonarQube Scanner for MSBuild failed (exit code 1)
Finished: FAILURE

The error says:

Caused by: org.tmatesoft.svn.core.SVNAuthenticationException

But I'm able to run sonarqube analysis on the project outside jenkings with sonar-scanner-2.6.1 and I see the results on http://localhost:9000/

AND

jenkins builds fine the project without the analysis step, so I don't understand how SVN authentication could be the problem. The Credentials are valid.

According to the official documentation http://docs.sonarqube.org/display/SCAN/From+Jenkins I have to configure a

MSBuild SonarQube Runner

but I only have an section called

SonarQube Scanner for MSBuild.

Have I missed something? What is the diffrance between runner and scanner?


回答1:


There are several different things going on here.

When you run analysis outside Jenkins I'm going to guess that you run it as a user that has cached SVN credentials on that machine. So the 'blame' portion of the analysis implicitly runs as you.

When you check the project out in Jenkins, you explicitly provide credentials to the job, and those credentials are explicitly used for that portion of the job.

When you run analysis in Jenkins, that portion of the job has no access to the cached credentials in use when you run analysis outside of Jenkins. Nor does it have access to the credentials you supplied Jenkins for the checkout. Instead. you'll need to go into your SonarQube server and configure those credentials into the project (you could also pass them as analysis parameters, but it's probably easier in the long run to add them to the project).

To do this, navigate to the project home page, then Administration > General Settings > SCM > SVN, and fill in your credentials there.



来源:https://stackoverflow.com/questions/38828746/ms-build-and-sonarqube-analysis-from-jenkins-unable-to-execute-sonar-e170001

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!