0

When running multiple different or parallel jobs in Jenkins that involve the SonarQube Scanner for MSBuild, this exception immediately terminates the build job:

10:46:22 [workspace] $ C:\Tools\SonarQube\sonar-scanner-msbuild-3.0.2.656
\MSBuild.SonarQube.Runner.exe begin /k:auth-services /n:auth-services /v:develop-b82 /d:sonar.host.url=http://redacted:9000 /d:sonar.cs.vscoveragexml.reportsPaths=C:\Jenkins\auth-services\auth-services-develop\workspace\VisualStudio.coveragexml /d:sonar.exclusions=node_modules/**,**/*.js
10:46:23 SonarQube Scanner for MSBuild 3.0.2
10:46:23 Default properties file was found at C:\Tools\SonarQube\sonar-scanner-msbuild-3.0.2.656\SonarQube.Analysis.xml
10:46:23 Loading analysis properties from C:\Tools\SonarQube\sonar-scanner-msbuild-3.0.2.656\SonarQube.Analysis.xml
10:46:23 Pre-processing started.
10:46:23 Preparing working directories...
10:46:23 10:46:23.814  Updating build integration targets...
10:46:23 
10:46:23 Unhandled Exception: System.IO.IOException: The file 'C:\Users\serviceaccount\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets' already exists.
10:46:23    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
10:46:23    at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
10:46:23    at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite)
10:46:23    at SonarQube.TeamBuild.PreProcessor.TargetsInstaller.CopyIfDifferent(String sourcePath, IEnumerable`1 destinationDirs, ILogger logger)
10:46:23    at SonarQube.TeamBuild.PreProcessor.TargetsInstaller.InternalCopyTargetsFile(ILogger logger)
10:46:23    at SonarQube.TeamBuild.PreProcessor.TargetsInstaller.InstallLoaderTargets(ILogger logger, String workDirectory)
10:46:23    at SonarQube.TeamBuild.PreProcessor.TeamBuildPreProcessor.InstallLoaderTargets(ProcessedArgs args)
10:46:23    at SonarQube.TeamBuild.PreProcessor.TeamBuildPreProcessor.DoExecute(ProcessedArgs localSettings)
10:46:23    at SonarQube.TeamBuild.PreProcessor.TeamBuildPreProcessor.Execute(String[] args)
10:46:23    at SonarQube.Bootstrapper.BootstrapperClass.PreProcess()
10:46:23    at SonarQube.Bootstrapper.BootstrapperClass.Execute()
10:46:23    at SonarQube.Bootstrapper.Program.Execute(String[] args, ILogger logger)
10:46:23    at SonarQube.Bootstrapper.Program.Main(String[] args)
10:46:23    at SonarQube.Old.Bootstrapper.Program.Main(String[] args)
10:46:26 ERROR: Execution of SonarQube Scanner for MSBuild failed (exit code 255)

Restarting the build job while no other jobs involving the scanner are running seems to successfully finish building.

test-in-prod
  • 498
  • 5
  • 19
  • You can find the sourcecode [here](https://github.com/SonarSource/sonar-scanner-msbuild/blob/master/SonarQube.TeamBuild.PreProcessor/TargetsInstaller.cs). Have also a look at InstallLoaderTargets in [this](https://github.com/SonarSource/sonar-scanner-msbuild/blob/ed32f00da4ab80b75fed6f4016aea612fc4aabac/SonarQube.TeamBuild.PreProcessor/TeamBuildPreProcessor.cs) file. – Jeroen Heier Oct 18 '17 at 19:47
  • Ok, I am not exactly sure what I should be seeing from this? Are you suggesting there's a way to override this CopyIfDifferent method call? – test-in-prod Oct 18 '17 at 20:36
  • Yes, but then you would use the same file every time. Your build results in a different file content (see the System.IO.IOException in your question). Given this source code the best option i see is split the parallel build over multiple build servers. – Jeroen Heier Oct 19 '17 at 04:02

0 Answers0