Failed to connect to localhost/ on Travis CI


In my last topic Sonarcloud: not authorized on Travis you help me to configure SonarCloud to the spring-framework-petclinic project:

I don’t change the travis configuration, but the Travis build failed since a few days:

I take a look a the Travis documentation and the Maven sample, but I don’t see any changes required:
Please could you help be?

If I understood correctly, we are talking about an external pull request which is considered an unsecure environment (since anyone can create them).
Unfortunately the sonarcloud addon doesn’t run and can’t set up the analysis based on the configuration in the YML fie.
We have a ticket to improve things but it doesn’t depend on us alone to find a solution.

The workaround is to skip in your script the execution of sonar:sonar if it’s a pull request in an unsafe environment (you can detect these 2 conditions using environment variables).

Thank you Duarte for your analyze. Yes, my error comes from an external pull request.
Did you have an example for the workaround?

I don’t have a working example of a work around.
However the script should look like this (not tested):

if [ "$TRAVIS_SECURE_ENV_VARS" = true ]; then 
  mvn clean verify sonar:sonar -Pcoverage -Dsonar.projectKey=spring-petclinic_spring-framework-petclinic
  mvn clean verify