We are currently migrate from on-prem SonarQube to SonarCloud. My build agent is on-prem behind a coporate proxy. The first step Prepare analysis work great and download the properties of my project on SonarCloud.
But during the second task Run Code Analysis, I have this error (Full log (1.2 MB)) :
ERROR: SonarQube server [https://sonarcloud.io] can not be reached
We have checked our proxy log and we have entry for the frist task but not for the second, which explains the error.
I have set HTTP_PROXY and HTTPS_PROXY environnement variables and I have try to add this options commands to the Prepare analysis task :
This seems to indicate a DNS issue.
Are you able to resolve sonarcloud.io from the machine having the issue? And are you able to run a curl or equivalent against it?
I think the proxy properties are not correctly passed. Could you please try to define the environment variable: SONAR_SCANNER_OPTS=-Dhttps.proxyHost=xxx -Dhttps.proxyPort=xxxx
on the agent before running the analyze task?
If that work I will create tickets to improve the situation.
After more thinking, I guess the prepare task is working because it is calling a dotnet executable under the hood, and I suppose you have defined your proxy settings in the Agent configuration. Dotnet programs automatically use system proxy config by default.
The analysis task is partially made of a Java program, and the HTTP library we are using is not supporting system proxy by default, it has to be enabled. Could you please test the following:
remove all proxy configuration from the prepare task (it should be useless)
change the environment variable SONAR_SCANNER_OPTS to SONAR_SCANNER_OPTS=-Djava.net.useSystemProxies=true
The benefit for you will be to avoid duplicating your proxy configuration in many different places (and for me I will have a better understanding of what’s going on, to choose the best strategy).
I tried to set SONAR_SCANNER_OPTS=-Djava.net.useSystemProxies=true with no succes. I back to the error ERROR: SonarQube server [https://sonarcloud.io] can not be reached.