我想在Sonarqube中扫描快速代码。我们有一个代理,我相信这是这个错误的根本原因。
我在mac机器的〜/ .bash_profile中设置了http_proxy,https_proxy和no_proxy env变量。
我在Mac节点(通过Jenkins)安装项目和声纳扫描仪
iOS项目构建工作正常。
当声纳扫描步骤运行时,我收到此错误。知道为什么会这样吗?
16:53:39 Unpacking https://repo1.maven.org/maven2/org/sonarsource/scanner/cli/sonar-scanner-cli/3.0.3.778/sonar-scanner-cli-3.0.3.778.zip to /Users/jenkins/home/jenkinsdata/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarqubeScanner on Mac-Agent
16:53:39 ERROR: Failed to download https://repo1.maven.org/maven2/org/sonarsource/scanner/cli/sonar-scanner-cli/3.0.3.778/sonar-scanner-cli-3.0.3.778.zip from agent; will retry from master
16:53:39 java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 407 Proxy Authentication Required"
16:53:39 at sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:2124)
16:53:39 at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:183)
16:53:39 at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1546)
16:53:39 at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
16:53:39 at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
16:53:39 at java.net.URL.openStream(URL.java:1045)
16:53:39 at hudson.FilePath$Unpack.invoke(FilePath.java:867)
16:53:39 at hudson.FilePath$Unpack.invoke(FilePath.java:861)
16:53:39 at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2750)
16:53:39 at hudson.remoting.UserRequest.perform(UserRequest.java:153)
16:53:39 at hudson.remoting.UserRequest.perform(UserRequest.java:50)
16:53:39 at hudson.remoting.Request$2.run(Request.java:336)
16:53:39 at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
16:53:39 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
16:53:39 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
16:53:39 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
16:53:39 at hudson.remoting.Engine$1$1.run(Engine.java:94)
16:53:39 at java.lang.Thread.run(Thread.java:748)
16:53:39 at ......remote call to JNLP4-connect connection from macHost/macHost:49506(Native Method)
16:53:39 at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1554)
16:53:39 at hudson.remoting.UserResponse.retrieve(UserRequest.java:281)
16:53:39 at hudson.remoting.Channel.call(Channel.java:839)
16:53:39 at hudson.FilePath.act(FilePath.java:987)
16:53:39 Caused: java.io.IOException: remote file operation failed: /Users/jenkins/home/jenkinsdata/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarqubeScanner at hudson.remoting.Channel@45df1f9e:JNLP4-connect connection from macHost/macHost:49506
16:53:39 at hudson.FilePath.act(FilePath.java:994)
16:53:39 at hudson.FilePath.act(FilePath.java:976)
16:53:39 at hudson.FilePath.installIfNecessaryFrom(FilePath.java:831)
16:53:39 at hudson.FilePath.installIfNecessaryFrom(FilePath.java:764)
16:53:39 at hudson.tools.DownloadFromUrlInstaller.performInstallation(DownloadFromUrlInstaller.java:77)
16:53:39 at hudson.tools.InstallerTranslator.getToolHome(InstallerTranslator.java:72)
16:53:39 at hudson.tools.ToolLocationNodeProperty.getToolHome(ToolLocationNodeProperty.java:109)
16:53:39 at hudson.tools.ToolInstallation.translateFor(ToolInstallation.java:206)
16:53:39 at hudson.plugins.sonar.SonarRunnerInstallation.forNode(SonarRunnerInstallation.java:104)
16:53:39 at hudson.plugins.sonar.SonarRunnerInstallation.forNode(SonarRunnerInstallation.java:62)
16:53:39 at hudson.plugins.sonar.utils.BuilderUtils.getBuildTool(BuilderUtils.java:70)
16:53:39 at hudson.plugins.sonar.SonarRunnerBuilder.perform(SonarRunnerBuilder.java:279)
16:53:39 at hudson.plugins.sonar.SonarRunnerBuilder.perform(SonarRunnerBuilder.java:261)
16:53:39 at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
16:53:39 at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:736)
16:53:39 at hudson.model.Build$BuildExecution.build(Build.java:206)
16:53:39 at hudson.model.Build$BuildExecution.doRun(Build.java:163)
16:53:39 at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:496)
16:53:39 at hudson.model.Run.execute(Run.java:1737)
16:53:39 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
16:53:39 at hudson.model.ResourceController.execute(ResourceController.java:97)
16:53:39 at hudson.model.Executor.run(Executor.java:419)
更新1
我将Mac机添加到Jenkins的no_proxy列表中。现在上面的错误消失了,但是得到以下错误。
我在浏览器中打开了sonarqube服务器并使用卷曲测试,如curl sonarqubeserverIP:9000,两者都正常。
我可以对同一台服务器上的Windows和Linux机器上的其他项目进行分析。
09:51:24 INFO: SonarQube Scanner 3.0.3.778
09:51:24 INFO: Java 1.8.0_144 Oracle Corporation (64-bit)
09:51:24 INFO: Mac OS X 10.12.6 x86_64
09:51:24 INFO: User cache: /Users/jenkins/.sonar/cache
09:51:24 ERROR: SonarQube server [http://SonarserverIP:9000] can not be reached
09:51:24 INFO: ------------------------------------------------------------------------
09:51:24 INFO: EXECUTION FAILURE
09:51:24 INFO: ------------------------------------------------------------------------
09:51:24 INFO: Total time: 0.411s
09:51:24 INFO: Final Memory: 4M/245M
09:51:24 INFO: ------------------------------------------------------------------------
09:51:24 ERROR: Error during SonarQube Scanner execution
09:51:24 org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQube
09:51:24 at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:84)
09:51:24 at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:71)
09:51:24 at java.security.AccessController.doPrivileged(Native Method)
09:51:24 at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:71)
09:51:24 at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:67)
09:51:24 at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:218)
09:51:24 at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:156)
09:51:24 at org.sonarsource.scanner.cli.Main.execute(Main.java:74)
09:51:24 at org.sonarsource.scanner.cli.Main.main(Main.java:61)
09:51:24 Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server
09:51:24 at org.sonarsource.scanner.api.internal.Jars.getBootstrapIndex(Jars.java:100)
09:51:24 at org.sonarsource.scanner.api.internal.Jars.getScannerEngineFiles(Jars.java:76)
09:51:24 at org.sonarsource.scanner.api.internal.Jars.download(Jars.java:70)
09:51:24 at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:39)
09:51:24 at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:75)
09:51:24 ... 8 more
09:51:24 Caused by: java.lang.IllegalStateException: Status returned by url [http://SonarserverIP:9000/batch/index] is not valid: [403]
09:51:24 at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:115)
09:51:24 at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:98)
09:51:24 at org.sonarsource.scanner.api.internal.Jars.getBootstrapIndex(Jars.java:96)
09:51:24 ... 12 more
09:51:24 ERROR:
09:51:24 ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
提前致谢。
答案 0 :(得分:0)
在访问Maven Central时,您必须通过身份验证代理才能使用Jenkins下载SonarQube扫描程序。
要解决您的问题,您需要使用凭据和代理配置配置Jenkins。您可以在此处找到更多详细信息:https://wiki.jenkins.io/display/JENKINS/JenkinsBehindProxy
根据您的更新1,SonarQube将返回403 http代码,表明您使用的凭据似乎不正确。