Error in MSBuild.Scanner end step

Hello community,

I ask for you help in an issue which gives not much information what exactly is going wrong in the end step.

Works with old setup:

  • Enterprise Edition Version 7.9.5 (build 38598)
  • Microsoft (R) Build Engine version 16.9.0+5e4b48a27 for .NET Framework
  • SonarScanner for MSBuild 4.10
  • using proxy environment

Works not with new 8.9 version:

  • Enterprise Edition Version 8.9 (build 43852)
  • Microsoft (R) Build Engine version 16.9.0+5e4b48a27 for .NET Framework
  • SonarScanner for MSBuild 4.10
  • using proxy environment

Target: running an analysis against v8.9
Error: in scanner end step (see attached log)
Interesting that the scanner begin command is able to resolve host

Things done so far:

Tried various settings of the SONAR_SCANNER_OPTS (also httpProxy, use system proxy etc.)

Log of the error in the end step:

"C:\Program Files (x86)\MSBuild.Scanner.4.10\SonarScanner.MSBuild.exe" end /d:sonar.login="*****" 
SonarScanner for MSBuild 4.10
Using the .NET Framework version of the Scanner for MSBuild
Post-processing started.
Using the supplied value for SONAR_SCANNER_OPTS. Value: "-Dsvnkit.http.methods=Basic,Digest,Negotiate,NTLM -Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128"
Calling the SonarQube Scanner...
INFO: Scanner configuration file: C:\Program Files (x86)\MSBuild.Scanner.4.10\sonar-scanner-4.4.0.2170\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: D:\Tests\.sonarqube\out\sonar-project.properties
INFO: SonarScanner 4.4.0.2170
INFO: Java 11.0.9.1 AdoptOpenJDK (64-bit)
INFO: Windows 10 10.0 amd64
INFO: SONAR_SCANNER_OPTS="-Dsvnkit.http.methods=Basic,Digest,Negotiate,NTLM -Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128"
INFO: User cache: C:\Users\*****\.sonar\cache
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 0.426s
ERROR: SonarQube server [https://sonar.*****.com] can not be reached
INFO: Final Memory: 3M/54M
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)
Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server
	at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:42)
	at org.sonarsource.scanner.api.internal.JarDownloader.getScannerEngineFiles(JarDownloader.java:58)
	at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:53)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:76)
	... 7 more
Caused by: java.net.UnknownHostException: No such host is known (sonar.*****.com)
	at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
	at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:929)
	at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1515)
	at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:848)
	at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1505)
	at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1364)
	at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1298)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.Dns.lambda$static$0(Dns.java:39)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:171)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RouteSelector.nextProxy(RouteSelector.java:135)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RouteSelector.next(RouteSelector.java:84)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.java:187)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.java:108)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.find(ExchangeFinder.java:88)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.Transmitter.newExchange(Transmitter.java:169)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:41)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.getResponseWithInterceptorChain(RealCall.java:221)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.execute(RealCall.java:81)
	at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:114)
	at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:99)
	at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:39)
	... 10 more
ERROR: 
The SonarQube Scanner did not complete successfully
13:25:36.401  Post-processing failed. Exit code: 1


Hi Armin,

The Scanner for MSBuild (since renamed to Scanner for .NET) has gone through a number of new releases since 4.10 – while I’m not aware of a specific change related to your problem description, there were some improvements involving network proxy handling that could be relevant. I suggest you try the latest 5.2.2 and report back.

Hi Jeff and many thanks for your response.

Tried it today with the version SonarScanner for MSBuild 5.2.2
Problem still persists.

Best regards,
Armin

Hi folks,

we’ve got another proxy related problem.

I don’t see in the source code that the MsBuild.Scanner 5.2.2 is processing the SONAR_SCANNER_OPTS environment variable in the begin step like it should according to the documentation:

SonarScanner for .NET

<=> no -Dhttps.proxyHost=<host> -Dhttps.proxyPort=<port> are read from the environment.

The class SonarScanner.MSBuild.PreProcessor.WebClientDownloader does not use any WebProxy for the HttpClientHandler it creates in the ctor, despite it needs that in order to get the bootstrap index from the server => fails at begin command with error message HTTP 407 - Proxy Authentication Required

What are the plans solving this?

Someone once had the similar problem:

However his pull request was not accepted:

Also consider -Djava.net.useSystemProxies=true is not a valid workaround in our company.
Like the closed and tagged “won’t fix” issue:

Hi Armin

Please see my response to this thread relating to your issue. In summary the documentation is unclear on this and you also need to set the .NET specific proxy settings. I’ll look at getting this updated shortly.

Tom