Failed to connect to localhost/127.0.0.1:9000 on Travis CI

Hi,

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

I don’t change the travis configuration, but the Travis build failed since a few days: https://travis-ci.org/spring-petclinic/spring-framework-petclinic

I take a look a the Travis documentation and the Maven sample, but I don’t see any changes required: https://docs.travis-ci.com/user/sonarcloud/
Please could you help be?

Hi,
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
else 
  mvn clean verify
fi