简体   繁体   中英

Sonar scanner in Mac failing analysis

I am tyring to scan swift code in Sonarqube. We have a proxy and I believe that is the root cause of this error.

I have set http_proxy,https_proxy and no_proxy env variables in ~/.bash_profile in mac machine.

I have setup project and sonar scanner in Mac node (via Jenkins)

iOS project build is working fine.

When sonar scan step runs, I am getting this error. Any idea why this is occuring?

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)

Update 1
I added Mac machine to no_proxy list in Jenkins. Now the above error is gone, but getting this below error.

I opened sonarqube server in a browser and tested using curl like curl sonarqubeserverIP:9000 and both works fine.

I am able to do analysis for other projects from windows and linux machines on same server.

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.

Thanks in advance.

It looks like that you have to go through a authenticating proxy when accessing Maven Central to download SonarQube scanner with Jenkins.

To solve your issue you need to configure Jenkins with your credentials and proxy configuration. You will find more details here : https://wiki.jenkins.io/display/JENKINS/JenkinsBehindProxy

According to your update 1, SonarQube is returning a 403 http code indicating that the credential you are using seems to be incorrect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM