Sonar-scanner does not respect -Dsonar.host.url?

I just changed the sonar server to push test coverage report, while found sonar-scanner only respect the sonar.host.url configuration from its conf/sonar-scanner.properties for plug-in cache updates, it did not care about the one assigned from cmdline. Is that expected? I assumed the options from cmdline should be taken with higher priority.

sonar-scanner -Dsonar.projectKey=engine-javaupoc-jacoco-trial -Dsonar.host.url=http://testhosta:9000 -Dsonar.coverage.jacoco.xmlReportPaths=javaxupoc-jacoco.xml -Dsonar.java.binaries=src\java -Dsonar.source= upoc\src\java -Dsonar.language=java -Dsonar.ws.timeout=600 -Dsonar.java.libraries=lib\clxjava.jar
INFO: Scanner configuration file: D:\sonar-scanner-4.3.0.2102-windows\bin…\conf\sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 4.3.0.2102
INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
INFO: Windows 10 10.0 amd64
INFO: User cache: C:\Users\twu.sonar\cache
ERROR: SonarQube server [http://localhost:9000] can not be reached
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 4.732s
INFO: Final Memory: 3M/17M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarScanner analysis
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:85)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:74)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:70)
at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:185)
at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:123)
at org.sonarsource.scanner.cli.Main.execute(Main.java:73)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Hello @wrenaashe,
The scanner should honor the -Dsonar.host.url parameter with the highest priority.

The INFO log where the scanner reads the default configuration file is normal
But then the scanner should override all config file parameters with what you pass on the command line. So the ERROR about trying to access http://localhost:9000 is not normal

There must be a problem in the way you pass the parameters to the scanner. Can you run the scanner again in debug (add -X cmd line option), collect the full console cmd and logs and attach to this thread.

Olivier

1 Like

Thanks, @OlivierK. I somehow must type something wrong in the cmdline. Now it looked good.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.