I have added the SonarQube - Begin Analysis and End Analysis tasks to my TFS Build definition. I have my SonarQube server up and running. I added a SonarQube Service endpoint and added it while configuring the SonarQube Begin analysis task.
However when I trigger the build, it fails throwing the below error - 'Unhandled Exception: System.IO.InvalidDataException: End of Central Directory record could not be found.'
Any idea what the issue might be? I am using SonarQube 6.5 version.
Starting: Get sources
Running tasks
Starting task: Fetch the Quality Profile from SonarQube
Executing the powershell script: c:\Program
Files\TFS2015Agent\tasks\SonarQubePreBuild\1.0.34\SonarQubePreBuild.ps1
SonarQube Scanner for MSBuild 1.1 Default properties file was not
found at C:\Program
Files\TFS2015Agent\tasks\SonarQubePreBuild\1.0.34\MSBuild.SonarQube.Runner-1.1\SonarQube.Analysis.xml
Pre-processing started. Preparing working directories... Checking for
updates... Unhandled Exception: System.IO.InvalidDataException: End of
Central Directory record could not be found.
at System.IO.Compression.ZipArchive.ReadEndOfCentralDirectory()
at System.IO.Compression.ZipArchive.Init(Stream stream, ZipArchiveMode mode, Boolean leaveOpen)
at System.IO.Compression.ZipArchive..ctor(Stream stream, ZipArchiveMode mode, Boolean leaveOpen, Encoding entryNameEncoding)
at System.IO.Compression.ZipFile.Open(String archiveFileName, ZipArchiveMode mode, Encoding entryNameEncoding)
at System.IO.Compression.ZipFile.ExtractToDirectory(String sourceArchiveFileName, String destinationDirectoryName, Encoding entryNameEncoding)
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)
To resolve the issue, I had to download the latest version of the SonarQube build tasks in TFS. The easiest option is to navigate to the Admin TFS Extension Page on the server and use it to download and install the updated SonarQube extension.
Once that was done, I triggered the TFS build and was able to get past this error.