Sonar-scanner doesn't take URL into consideration

Template for a good new topic, formatted with Markdown:

  • ALM used GitHub
  • CI system used GitHub Actions
  • Scanner command used when applicable
sonar-scanner -Dsonar.organization=REDACTED -Dsonar.projectKey=REDACTED -Dsonar.sources=REDACTED -Dsonar.host.url="https://sonarcloud.io" -Dsonar.login="***"
  • Languages of the repository Javascript and Typescript

  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)

2020-05-18T17:26:15.6952756Z INFO: Scanner configuration file: /home/runner/.sonar/sonar-scanner-4.2.0.1873-linux/conf/sonar-scanner.properties
2020-05-18T17:26:15.6953027Z INFO: Project root configuration file: NONE
2020-05-18T17:26:15.7226851Z INFO: SonarQube Scanner 4.2.0.1873
2020-05-18T17:26:15.7228017Z INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
2020-05-18T17:26:15.7230185Z INFO: Linux 5.3.0-1020-azure amd64
2020-05-18T17:26:15.9939243Z INFO: User cache: /home/runner/.sonar/cache
2020-05-18T17:26:16.0336179Z ERROR: SonarQube server [http://localhost:9000] can not be reached
2020-05-18T17:26:16.0338514Z INFO: ------------------------------------------------------------------------
2020-05-18T17:26:16.0338715Z INFO: EXECUTION FAILURE
2020-05-18T17:26:16.0339934Z INFO: ------------------------------------------------------------------------
2020-05-18T17:26:16.0343291Z INFO: Total time: 0.341s
2020-05-18T17:26:16.0433588Z INFO: Final Memory: 2M/14M
2020-05-18T17:26:16.0434434Z INFO: ------------------------------------------------------------------------
2020-05-18T17:26:16.0436730Z ERROR: Error during SonarQube Scanner execution

For some reason sonar-scanner doesn’t pick up on the -DSonar.host.url=“https://sonarcloud.io” and looks for a local SonarQube.

Could you please help?

1 Like

Hello @Vincent-FundApps,

This is unexpected behaviour, the arguments passed by the command-line should always take precedence over anything else. Is it possible you might have improperly closed some ' or " in the previous arguments? Try moving -Dsonar.host.url to be the first argument passed.

Besides that you mention you use GitHub Actions, you might want to have a look at our SonarCloud GitHub Action. You won’t have to specify the sonar.host.url parameter when using this action.

2 Likes

Hi Tom,
Unfortunately I can’t use your GitHub Action because it requires sonar-cloud.properties files. I’m scanning a repository for js and tsx, which is already scanned by the dotnet scanner for C#. If I add a sonar-cloud.properties file the other scan will fail.

I found what was the problem. As you guessed it was an issue with the previous arguments, which didn’t have quotes.

I fixed that and it works as a charm.

Thanks Tom.

1 Like