Error in Run Code Analysis with coporate proxy

sonarcloud
(Matthieu Truchet) #1

Hi,

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 :

https.proxyHost=proxy
https.proxyPort=8080
http.proxyHost=proxy
http.proxyPort=8080
  • Version : SonarCloud on Azure DevOps with SonarCloud 1.6.0
(Matthieu Truchet) #2

Any body to solve my problem ?

(Alex Odoux) #3

Hi Matthieu,

Did you notice this line in your log?
Caused by: java.net.UnknownHostException: Ceci est habituellement une erreur temporaire qui se produit durant la résolution du nom d’hôte et qui signifie que le serveur local n’a pas reçu de réponse d’un serveur faisant autorité

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?

(Matthieu Truchet) #4

Hi Alex,

Yes I can resolve sonarcloud.io because, the frist task “Prepare analysis” work fine and contact sonarcloud.io with success.

It’s seems that the proxy is not use for the second task “Run analysis” evne if it’s defined.

(Julien Henry) #5

Hi @truche_m

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.

1 Like
(Matthieu Truchet) #6

Hi @Julien_HENRY

That works if I defined the environnement variable :
SONAR_SCANNER_OPTS=-Dhttps.proxyHost=xxx -Dhttps.proxyPort=xxxx

I look forward to the improvement :wink:

Thank you

(Julien Henry) #7

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).

Thanks

1 Like
(Matthieu Truchet) #8

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.

(Julien Henry) #9

How is your proxy configured on the Agent? Do you confirm that removing properties from the prepare task is harmless?

(Matthieu Truchet) #10

My agent have a .proxy file with the proxy address and I have the environment variables :

  • HTTP_PROXY
  • HTTPS_PROXY

And yes I have remove the properties from the prepare task

(Julien Henry) #11

OK, I think I have now a good understanding, I added details to:
https://jira.sonarsource.com/browse/VSTS-175

Thanks for your feedback

(Matthieu Truchet) #12

Thank you for your help and your workaround.