Search code examples
sonarqubesonar-runnersonarqube-msbuild-runner

MSBuild SonarQube Runner Proxy Authentication


When running MSBuild.SonarQube.Runner.exe (version 2.0), I receive the following error:

SonarQube Scanner for MSBuild 2.0
Default properties file was found at C:\path-to-sonar\SonarQube.Analysis.xml
Loading analysis properties from C:\path-to-sonar\SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories...
Checking for updates...

Unhandled Exception: System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required.
   at System.Net.WebClient.DownloadFile(Uri address, String fileName)
   at System.Net.WebClient.DownloadFile(String address, String fileName)
   at SonarQube.Bootstrapper.BuildAgentUpdater.TryUpdate(String hostUrl, String targetDir, ILogger logger)
   at SonarQube.Bootstrapper.Program.PreProcess(IBuildAgentUpdater updater, IBootstrapperSettings settings, ILogger logger)
   at SonarQube.Bootstrapper.Program.Execute(String[] args, IBuildAgentUpdater updater, ILogger logger)
   at SonarQube.Bootstrapper.Program.Main(String[] args)

This Is being run on a Jenkins Windows slave, which does, in fact, require proxy authentication. The SonarQube server is not the same server as the Jenkins master or slave.

Update Center is turned off at the server, and I've even tried including the following property in the SonarQube.Analysis.xml file (just for grins):

<Property Name="sonar.updatecenter.active">false</Property>

Is it possible to turn off the update feature in MSBuild SonarQube Runner?


Solution

  • Although potentially confusing, this Checking for updates log is not at all related to the Update Center. It means the Scanner is talking to the SonarQube server to check for some updated binaries. So rest assured it's not trying to reach a public Update Center URL.

    Last I checked the scanners do not support proxy authentication. However I would assume Jenkins slaves/master and SonarQube server to be in the same network location, i.e. not separated by a proxy. I suggest you whitelist SonarQube's URL so that it gets contacted directly by the scanners without going through the proxy.

    Update: new capabilities are being delivered on the SonarQube Scanner side, including proxy authentication. See SCANNERAPI-77 for more details (it links to tickets specific for each Scanner).