Gradle task :sonarqube fails on Travis with wrong host

I am trying to set up a project on GitHub with Travis and SonarCloud.

This was working fine at the beginning (including SonarCloud), but then my builds suddenly started failing in the :sonarqube step. I can reproduce this on my “infrastructure” branch which has basically no code on it. Here’s a passing build:
Then, without any significant change, the builds start failing. Here the first fail on that branch:
The error I get is:

Task :sonarqube FAILED
SonarQube server [http://localhost:9000] can not be reached

It confuses me that it tries to contact localhost. Is there some local dummy server which forwards this to the cloud? I tried to change the URL and point it to, but with this I get a different error:

Execution failed for task ':sonarqube'.
You're not authorized to run analysis. Please contact the project administrator.

So maybe it was not a good idea to point it to / Or is something wrong with my credentials?

Can someone help to understand what is going on here? It is somehow mysterious to me why a working setup would suddenly break. I am also wondering what is a good way to debug this. And then, how can I fix it?

I had a look at the example project on github (, but this is completely different and not building either.

Hello Mark!

Welcome to our community forum!

I think the issue here comes from the fact that you are configuring your project both to use the Travis-CI addon and gradle scanner. You should choose one or the other and keep only one. IMO you should stick to the Travis-CI addon which is easier to set up.

Tavis-CI Addon

With your current configuration it’s not run at all. But if you decide to use the Travis-CI addon you can follow the SonarCloud with Travis CI documentation.

You can also drop the sonarqube part of you file and you should replace your - ./gradlew sonarqube task in your travis.yaml file by - sonar-scanner.

Gradle Scanner

And if you want to use the gradle scanner (which is a bit less well integrated with SonarCloud than the Travis-CI addon), you can follow the SonarScanner for Gradle documentation.

And you will also need to clean your travis.yaml file from the SonarCloud addon configuration. And in your build.gradle file you will need to setup the host.url to target the SonarCloud server, your projectKey, organizationKey and secure token.

Your two errors are related to the gradle scanner running:

  • the first one is because the default value for the gradle scanner is to target a local sonarqube server that would be available at http://localhost:9000
  • the second one, after you started target the sonarcloud server, is because your configuration is missing the target organization and the secure token to have the right to push your analysis to SonarCloud

Hi Grégoire,

Thank you very much for your advice and your good explanations! I switched to the Travis-CI Addon and it works smoothly. And I think I now have a better understanding about what I was doing :wink:
Here’s the passing build as a reference:

Best regards,

1 Like