Hi,
I am quite new to sonarcloud . I used to be able to use the sonar-scanner for ant to scan our java code for SonarQube (installed inhouse).
Now our company switched to use sonarcloud.io and our LINUX machine does not have internet access directly. It has to go through a proxy server
in my environment, there is
env | grep http
http_proxy=http://xx.xx.xx.xxx:yyyy
https_proxy=http://xx.xx.xx.xxx:yyyy
if I do a “wget sonarcloud.io” , the output is
wget sonarcloud.io
–2024-03-08 23:07:25-- http://sonarcloud.io/
Connecting to xx.xx.xx.xxx:yyyy… connected.
Proxy request sent, awaiting response… 301 Moved Permanently
Location: https://sonarcloud.io/ [following]
–2024-03-08 23:07:25-- https://sonarcloud.io/
Connecting to xx.xx.xx.xxx:yyyy… connected.
Proxy request sent, awaiting response… 307 Temporary Redirect
Location: SonarCloud Online Code Review as a Service Tool [following]
–2024-03-08 23:07:25-- SonarCloud Online Code Review as a Service Tool
Connecting to xx.xx.xx.xxx:yyyy… connected.
Proxy request sent, awaiting response… 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html.1’
[ <=> ] 252,063 --.-K/s in 0.06s
2024-03-08 23:07:25 (3.83 MB/s) - ‘index.html.1’ saved [252063]
It seems the proxy is working and it can connect to sonarcloud.io
But when I tried to run the sonar-scanner command, it always says
ERROR: SonarCloud server [https://sonarcloud.io] can not be reached
I have tried different variations of the command with or without specifying https.proxyHost and https.proxyPort
- sonar-scanner -Dsonar.host.url=https://sonarcloud.io/ -Dsonar.token=xxxxxxxx -X
- sonar-scanner -Dsonar.host.url=https://sonarcloud.io -Dsonar.token=xxxxxxxx -Dhttps.proxyHost=http://xx.xx.xx.xxx/ -Dhttps.proxyPort=yyyy -X
- sonar-scanner -Dsonar.host.url=http://sonarcloud.io -Dsonar.token=xxxxxxxx -Dhttps.proxyHost=xx.xx.xx.xxx -Dhttps.proxyPort=yyyy
and their results are look alike
22:45:24.309 INFO: SonarScanner 4.7.0.2747
22:45:24.310 INFO: Java 11.0.14.1 Eclipse Adoptium (64-bit)
22:45:24.310 INFO: Linux 3.10.0-1160.25.1.0.1.el7.x86_64 amd64
22:45:24.427 DEBUG: keyStore is :
22:45:24.427 DEBUG: keyStore type is : pkcs12
22:45:24.427 DEBUG: keyStore provider is :
22:45:24.427 DEBUG: init keystore
22:45:24.427 DEBUG: init keymanager of type SunX509
22:45:24.526 DEBUG: Create: pwd
/.sonar/cache
22:45:24.528 INFO: User cache: pwd
/.sonar/cache
22:45:24.528 DEBUG: Create: pwd
/.sonar/cache/_tmp
22:45:24.530 DEBUG: Extract sonar-scanner-api-batch in temp…
22:45:24.533 DEBUG: Get bootstrap index…
22:45:24.533 DEBUG: Download: https://sonarcloud.io/batch/index
22:47:24.766 ERROR: SonarCloud server [https://sonarcloud.io] can not be reached
22:47:24.766 INFO: ------------------------------------------------------------------------
22:47:24.766 INFO: EXECUTION FAILURE
22:47:24.766 INFO: ------------------------------------------------------------------------
22:47:24.766 INFO: Total time: 2:00.492s
22:47:24.783 INFO: Final Memory: 3M/40M
22:47:24.784 INFO: ------------------------------------------------------------------------
22:47:24.784 ERROR: Error during SonarScanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarScanner analysis
.
.
.
Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server
.
.
.
Caused by: java.net.SocketTimeoutException: connect timed out
.
.
.
the sonar-project.properties file in my project is very basic
sonar.projectKey=“ZZZZZZ”
sonar.projectName=“ZZZZZZ”
sonar.projectVersion=“1.0”
sonar.language=“java”
sonar.sources=“src”
sonar.java.binaries=“dist”
sonar.sourceEncoding=“UTF-8”
sonar.userHome=pwd
/.sonar
And i did not configure the sonar-scanner.properties file
Hope someone with more knowledge can point out what I have been missing in my setup
Thanks,
James