Sonar Scanner MSBuild for C# Project inside Docker build

Trying to run sonar scan using sonar scanner msbuild part of the docker build alongside Application build using sonarscanner begin and end commands. The Sonarscanner end is failing with unable to connect(connect timeout) when configured to connect via corporate proxy.

I’ve added Proxy env variables that are required for dotnet scanner and also added SONAR_SCANNER_OPTS = “-Dhttp.proxyHost=yourProxyHost -Dhttp.proxyPort=yourProxyPort” as environment variables(this is just an example but I’ve replaced with actual values).

Still no luck and seeing the can’t connect and connection timed out error

here are the logs from our CI/CD pipeline:

#35 31.59 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
#35 31.59 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
#35 31.59 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)
#35 31.59 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
#35 31.59 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
#35 31.59 at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.getResponseWithInterceptorChain(RealCall.java:221)
#35 31.59 at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.execute(RealCall.java:81)
#35 31.59 at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:115)
#35 31.59 at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:99)
#35 31.59 at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:39)
#35 31.59 … 10 more
#35 31.59 ERROR:
#35 31.60 The SonarScanner did not complete successfully
#35 31.60 03:00:54.148 Post-processing failed. Exit code: 1
#35 ERROR: process “/bin/sh -c dotnet sonarscanner end /d:sonar.token="${SONAR_TOKEN}"” did not complete successfully: exit code: 1

Hey there.

Have you read these docs, which mention also setting environment variables other than SONAR_SCANNER_OPTS?

You also need to set the appropriate proxy environment variables used by .NET. HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, and NO_PROXY are all supported. You can find more details here.

Please also make sure you include full logs from the scanner, not just the last few lines of the logs. :slight_smile: It’s impossible to know what was going on before!

Please attach the complete logs from dotnet sonarscanner end!

Have you tried using https.proxyHost rather than http.proxyHost?