SonarQube scanner for MSBuild - end analysis step failing


(Adam McLellan) #1

Hi all,

I’m evaluating SonarQube for static code analysis of our TFS 2015 CI builds. Unfortunately, I’m running into an issue with the SonarQube Scanner for MSBuild extension (3.1.0): the begin analysis step runs just fine, but the end analysis step is failing (log output below).

The most obvious error appears to be related to JAVA_HOME not being set, but I have confirmed that the TFS build agent does indeed have this set properly. I’m thinking it might be a red herring, but if so I’m not sure where to look next.

Any help is greatly appreciated. SonarQube server version is 7.4.

2018-12-12T18:24:00.5139115Z Starting task: Complete the SonarQube analysis
2018-12-12T18:24:00.5139115Z Executing the powershell script: E:\agent\tasks\SonarQubeScannerMsBuildEnd\3.1.0\SonarQubePostTest.ps1
2018-12-12T18:24:00.5607864Z ##[debug]Starting SonarQube PostBuild Step
2018-12-12T18:24:00.5607864Z ##[debug]Loading module from path 'E:\agent\agent\worker\Modules\Microsoft.TeamFoundation.DistributedTask.Task.Common\Microsoft.TeamFoundation.DistributedTask.Task.Common.dll'.
2018-12-12T18:24:00.5607864Z ##[debug]Importing cmdlet 'Complete-Task'.
2018-12-12T18:24:00.5607864Z ##[debug]Importing cmdlet 'Get-LocalizedString'.
2018-12-12T18:24:00.5607864Z ##[debug]Importing cmdlet 'Set-TaskVariable'.
2018-12-12T18:24:00.5607864Z ##[debug]Importing cmdlet 'Set-TaskProgress'.
2018-12-12T18:24:00.5607864Z ##[debug]Importing cmdlet 'Add-TaskIssue'.
2018-12-12T18:24:00.5607864Z ##[debug]Importing cmdlet 'Write-TaskDetail'.
2018-12-12T18:24:00.5607864Z ##[debug]Importing cmdlet 'Find-Files'.
2018-12-12T18:24:00.6076648Z ##[debug]Variable read: MSBuild.SonarQube.Internal.BootstrapperPath = E:\agent\tasks\SonarQubeScannerMsBuildBegin\3.1.0\SonarQubeScannerMsBuild\MSBuild.SonarQube.Runner.exe
2018-12-12T18:24:00.6076648Z ##[debug]bootstrapperPath: E:\agent\tasks\SonarQubeScannerMsBuildBegin\3.1.0\SonarQubeScannerMsBuild\MSBuild.SonarQube.Runner.exe
2018-12-12T18:24:00.6076648Z ##[debug]Variable read: MSBuild.SonarQube.ServerUsername = ********
2018-12-12T18:24:00.9514158Z ##[debug]Variable read: MSBuild.SonarQube.ServerPassword = 
2018-12-12T18:24:00.9514158Z ##[debug]Variable read: MSBuild.SonarQube.DbUsername = 
2018-12-12T18:24:00.9514158Z ##[debug]Variable read: MSBuild.SonarQube.DbPassword = 
2018-12-12T18:24:00.9514158Z ##[debug]Running batch script.
2018-12-12T18:24:00.9514158Z ##[debug]   Path: E:\agent\tasks\SonarQubeScannerMsBuildBegin\3.1.0\SonarQubeScannerMsBuild\MSBuild.SonarQube.Runner.exe
2018-12-12T18:24:00.9514158Z ##[debug]   Arguments: end /d:sonar.login="********"
2018-12-12T18:24:00.9514158Z ##[debug]   WorkingFolder: 
2018-12-12T18:24:01.2951699Z SonarQube Scanner for MSBuild 4.0
2018-12-12T18:24:01.2951699Z Default properties file was found at E:\agent\tasks\SonarQubeScannerMsBuildBegin\3.1.0\SonarQubeScannerMsBuild\SonarQube.Analysis.xml
2018-12-12T18:24:01.2951699Z Loading analysis properties from E:\agent\tasks\SonarQubeScannerMsBuildBegin\3.1.0\SonarQubeScannerMsBuild\SonarQube.Analysis.xml
2018-12-12T18:24:01.2951699Z Post-processing started.
2018-12-12T18:24:01.6233406Z 14:24:01.42  14:24:01.404  WARNING: Failed to find the code coverage command line tool. Possible cause: Visual Studio is not installed, or the installed version does not support code coverage.
2018-12-12T18:24:01.6233406Z WARNING: File 'E:\Builds\11\s\Eastlink.ca\OpenContentTemplates\Templates\WEP_TitleIcon\images\security-icon.svg' does not exist.
2018-12-12T18:24:01.6233406Z WARNING: File 'E:\Builds\11\s\Eastlink.ca\WebEvolution_Skin\scss\partials\_cta-multi.scss' does not exist.
2018-12-12T18:24:01.8420568Z SONAR_SCANNER_OPTS is not configured. Setting it to the default value of -Xmx1024m
2018-12-12T18:24:01.8420568Z Calling the SonarQube Scanner...
2018-12-12T18:24:01.8420568Z ERROR: JAVA_HOME not found in your environment, and no Java
2018-12-12T18:24:01.8420568Z executable present in the PATH.
2018-12-12T18:24:01.8420568Z Please set the JAVA_HOME variable in your environment to match the
2018-12-12T18:24:01.8420568Z location of your Java installation, or add "java.exe" to the PATH
2018-12-12T18:24:01.8420568Z ##[error]The SonarQube Scanner did not complete successfully
2018-12-12T18:24:01.8420568Z 14:24:01.779  Creating a summary markdown file...
2018-12-12T18:24:01.8420568Z ##[error]14:24:01.779  Post-processing failed. Exit code: 1
2018-12-12T18:24:01.8889285Z ##[error]System.Exception: Unexpected exit code received from batch file: 1
2018-12-12T18:24:01.8889285Z ##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.PowerShell.InvokeBatchScriptCmdlet.ProcessRecord()
2018-12-12T18:24:01.8889285Z ##[error]   at System.Management.Automation.CommandProcessor.ProcessRecord()
2018-12-12T18:24:01.9045641Z ##[debug]The build was not triggered by a Pull Request, not processing code analysis comments
2018-12-12T18:24:01.9045641Z ##[debug]Variable read: MSBuild.SonarQube.Internal.IncludeFullReport = true
2018-12-12T18:24:01.9357980Z ##[debug]Variable read: MSBuild.SonarQube.Internal.ServerVersion = 
2018-12-12T18:24:01.9982968Z ##[debug]Calling InvokeGetRestMethod "/api/server/version" 
2018-12-12T18:24:02.0295494Z ##[debug]Variable read: MSBuild.SonarQube.HostUrl = http://hfxvmstfo:9000/
2018-12-12T18:24:02.0608024Z ##[debug]Variable read: MSBuild.SonarQube.ServerUsername = ********
2018-12-12T18:24:02.0608024Z ##[debug]Variable read: MSBuild.SonarQube.ServerPassword = 
2018-12-12T18:24:02.1545632Z ##[debug]GET http://hfxvmstfo:9000/api/server/version with 0-byte payload
2018-12-12T18:24:02.1701721Z ##[debug]received 11-byte response of content type text/plain
2018-12-12T18:24:02.2185281Z ##[debug]The SonarQube server version is 7.4.0.18908
2018-12-12T18:24:02.2649785Z Waiting on the SonarQube server to finish processing in order to determine the quality gate status.
2018-12-12T18:24:02.2806017Z ##[debug]Variable read: Agent.BuildDirectory = E:\Builds\11
2018-12-12T18:24:02.2806017Z ##[debug]Could not find the task details file at E:\Builds\11\.sonarqube\out\.sonar\report-task.txt
2018-12-12T18:24:02.3274743Z ##[error]System.Management.Automation.RuntimeException: Cannot determine if the analysis has finished. Possible cause: your SonarQube server version is lower than 5.3 - for more details see https://go.microsoft.com/fwlink/?LinkId=722407 ---> System.Management.Automation.RuntimeException: Cannot determine if the analysis has finished. Possible cause: your SonarQube server version is lower than 5.3 - for more details see https://go.microsoft.com/fwlink/?LinkId=722407
2018-12-12T18:24:02.3274743Z ##[error]   --- End of inner exception stack trace ---
2018-12-12T18:24:02.3274743Z ##[error]   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
2018-12-12T18:24:02.3274743Z ##[error]   at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
2018-12-12T18:24:02.3274743Z ##[error]   at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
2018-12-12T18:24:02.3274743Z ##[error]   at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
2018-12-12T18:24:02.3274743Z ##[error]   at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
2018-12-12T18:24:02.3274743Z ##[error]   at Microsoft.TeamFoundation.DistributedTask.Handlers.PowerShellHandler.Execute(ITaskContext context, CancellationToken cancellationToken)
2018-12-12T18:24:02.3274743Z ##[error]   at Microsoft.TeamFoundation.DistributedTask.Worker.JobRunner.RunTask(ITaskContext context, TaskWrapper task, CancellationTokenSource tokenSource)
2018-12-12T18:24:02.3431077Z Finishing task: SonarQubeScannerMsBuildEnd
2018-12-12T18:24:02.3431077Z ##[error]System.Exception: Task SonarQubeScannerMsBuildEnd failed. This caused the job to fail. Look at the logs for the task for more details.
2018-12-12T18:24:02.3431077Z ##[error]   at Microsoft.TeamFoundation.DistributedTask.Worker.JobRunner.Run(IJobContext jobContext, IJobRequest job, IJobExtension jobExtension, CancellationTokenSource tokenSource)
2018-12-12T18:24:02.3587237Z Entering OnFinalizeJob
2018-12-12T18:24:02.3587237Z Leaving OnFinalizeJob