0

For all .NET Framework and .NET Core projects in our TFS server 2018 the sonar scan does not finish scan after updatet to version 3.1.0.

We have the following build configuration in TFS server 2018, for a .NET Framework project: Build configuration

The build breaks on the complete analyse step with the following error:

2018-01-16T09:28:19.5905262Z ##[error]No analysable projects were found. SonarQube analysis will not be performed. Check the build summary report for details. 2018-01-16T09:28:19.5905262Z Generation of the sonar-properties file failed. Unable to complete SonarQube analysis. 2018-01-16T09:28:19.5905262Z 10:28:19.543 Creating a summary markdown file... 2018-01-16T09:28:19.5905262Z

[error]10:28:19.543 Post-processing failed. Exit code: 1 2018-01-16T09:28:19.5905262Z ##[error]System.Exception: Unexpected

exit code received from batch file: 1 2018-01-16T09:28:19.5905262Z

[debug]Processed: ##vso[task.logissue type=error;]System.Exception: Unexpected exit code received from batch file: 1

2018-01-16T09:28:19.5905262Z at Microsoft.TeamFoundation.DistributedTask.Task.Internal.InvokeBatchScriptCmdlet.ProcessRecord() 2018-01-16T09:28:19.5905262Z at System.Management.Automation.CommandProcessor.ProcessRecord() 2018-01-16T09:28:19.5905262Z ##[debug]The build was not triggered by a Pull Request, not processing code analysis comments 2018-01-16T09:28:19.5905262Z ##[debug]Invoke - Get-TaskVariable cmdlet 2018-01-16T09:28:19.5905262Z ##[debug]Variable read: MSBuild.SonarQube.Internal.IncludeFullReport = true 2018-01-16T09:28:19.6061603Z ##[debug]Invoke - Get-TaskVariable cmdlet 2018-01-16T09:28:19.6061603Z ##[debug]Variable read: MSBuild.SonarQube.Internal.ServerVersion = 2018-01-16T09:28:19.6217771Z ##[debug]Calling InvokeGetRestMethod "/api/server/version" 2018-01-16T09:28:19.6374047Z ##[debug]Invoke - Get-TaskVariable cmdlet 2018-01-16T09:28:19.6374047Z ##[debug]Variable read: MSBuild.SonarQube.HostUrl = https://sonar.MyOrganisation.nl/ 2018-01-16T09:28:19.6530505Z ##[debug]Invoke - Get-TaskVariable cmdlet 2018-01-16T09:28:19.6530505Z ##[debug]Variable read: MSBuild.SonarQube.ServerUsername = ******** 2018-01-16T09:28:19.6530505Z ##[debug]Invoke - Get-TaskVariable cmdlet 2018-01-16T09:28:19.6530505Z ##[debug]Variable read: MSBuild.SonarQube.ServerPassword = 2018-01-16T09:28:19.6842912Z

[debug]GET https://sonar.MyOrganisation.nl/api/server/version with 0-byte payload 2018-01-16T09:28:19.7155095Z ##[debug]received 11-byte

response of content type text/plain; charset=UTF-8 2018-01-16T09:28:19.7323972Z ##[debug]Processed:

vso[task.setvariable variable=MSBuild.SonarQube.Internal.ServerVersion;]6.7.1.35068

2018-01-16T09:28:19.7323972Z 2018-01-16T09:28:19.7323972Z 2018-01-16T09:28:19.7323972Z ##[debug]The SonarQube server version is 6.7.1.35068 2018-01-16T09:28:19.7467772Z Waiting on the SonarQube server to finish processing in order to determine the quality gate status. 2018-01-16T09:28:19.7467772Z 2018-01-16T09:28:19.7467772Z 2018-01-16T09:28:19.7467772Z ##[debug]Invoke - Get-TaskVariable cmdlet 2018-01-16T09:28:19.7467772Z ##[debug]Variable read: Agent.BuildDirectory = d:/_work\3 2018-01-16T09:28:19.7624290Z

[debug]Could not find the task details file at d:/_work\3.sonarqube\out.sonar\report-task.txt

2018-01-16T09:28:19.7936587Z

[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-01-16T09:28:19.7936587Z ##[debug]Processed: ##vso[task.logissue type=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-01-16T09:28:19.7936587Z --- End of inner exception stack trace --- 2018-01-16T09:28:19.7936587Z at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) 2018-01-16T09:28:19.7936587Z at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke) 2018-01-16T09:28:19.7936587Z at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync) 2018-01-16T09:28:19.7936587Z at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection1 input, PSDataCollection1 output, PSInvocationSettings settings) 2018-01-16T09:28:19.7936587Z at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection1 input, PSDataCollection1 output, PSInvocationSettings settings) 2018-01-16T09:28:19.7936587Z at Microsoft.TeamFoundation.DistributedTask.Handlers.LegacyVSTSPowerShellHost.VSTSPowerShellHost.Main(String[] args) 2018-01-16T09:28:19.8092817Z

[error]LegacyVSTSPowerShellHost.exe completed with return code: -1. 2018-01-16T09:28:19.8092817Z ##[section]Finishing: Complete the

SonarQube analysis

I have checked the build log in debug mode, but i can't see anything wrong.

Temp location with the full log with debug mode: https://onedrive.live.com/?authkey=%21ADdDbeYD4oxJ9NA&id=5A1F84872B7BA3C1%21952&cid=5A1F84872B7BA3C1

Note that i have replaced my organisation name with: myorganiation and the project name with MyProject in the log.

Michael Vonck
  • 296
  • 2
  • 5
  • 1
    The csc.exe entries in the build logs should specify /analyzer parameters, but they don't, although they do have the expected /additionalfile setting. * are you using a hosted agent or a custom agent? * could you run the analysis again with verbose output? Set the Additional Settings in the "Prepare" step to /d:sonar.verbose=true – duncanp Jan 25 '18 at 17:10
  • Thx for looking. We are using custom agents with Visual Studio 2017. I have updated the logs in the share where i have used /d:sonar.verbose=true – Michael Vonck Jan 26 '18 at 08:57
  • Thanks. I'd have expected to see more log entries in the Prepare step e.g. about analysers being downloaded. The Prepare step will have generated a file in agent working folder called SonarQubeAnalysisConfig.xml (e.g. C:\agent\_work\[xxx]\.sonarqube\conf\SonarQubeAnalysisConfig.xml). Could you share a sanitized version of that file please? (there won't be any secrets in it, but there might be other settings you want to obscure). Also, which version of the C# plugin do you have installed on your SonarQube server? – duncanp Jan 26 '18 at 17:14
  • I don't have enough rights on the company sonar server, but i will check after the weekend. – Michael Vonck Jan 26 '18 at 22:30
  • Our C# plugin in Sonar is version 6.7.1. I have tried a few things myself. When downgrading the scanner on the build agent manualy: 'D:\_work\_tasks\SonarQubeScannerMsBuildBegin_15b84ca1-b62f-4a2a-a403-89b77a063157\3.1.0\SonarQubeScannerMsBuild' with 'sonar-scanner-msbuild-3.0.2.656', the scanner works again. When i open the quality profiles on sonar, i see that the C# profile is not updated for 3 years. I'm going to try to update the profile later this day, maybey that is the solution. – Michael Vonck Jan 29 '18 at 07:46
  • Updating the C# quality profile did't work. I have uploaded C:\agent_work[xxx]\.sonarqube\conf\SonarQubeAnalysisConf‌​ig.xml to the share for you. I hope you see the problem. – Michael Vonck Jan 29 '18 at 12:31
  • The SonarQubeAnalysisConfig.xml file looks ok. It's interesting that downgrading the scanner manually worked, although I don't know what at the moment. Downgrading the VSTS task to version 2.* would use version 2.3 of the scanner for MSBuild, although I can't remember what other changes there were between version 3 and 2. Could you upload the generated ruleset please? (d:\_work\3\.sonarqube\conf\SonarQubeRoslyn-cs.ruleset) I'm not sure what else to suggest, short of running MSBuild with full diagnostic output which will be extremely verbose. – duncanp Feb 01 '18 at 21:01
  • Version 4.0.1 has come out, i will try to use this one first later today or tommorow. If this works i will let you know. – Michael Vonck Feb 05 '18 at 08:11
  • It is working! I have configured a build agent on my laptop and then the analyze works. After comparing logs a long time i have found it. And this topic helpt me https://stackoverflow.com/questions/23696251/sonarqube-does-not-analyze-files-after-upgrade-from-4-2-to-4-3/23708680#23708680. It was de working path for the build agent. We had it configured like this: "workFolder": "d:/_work" but the correct path must be: "workFolder": "d:\\_work" – Michael Vonck Feb 16 '18 at 19:51

1 Answers1

0

It is working! I have configured a build agent on my laptop and then the analyze works. After comparing logs a long time i have found it. And this topic helpt me stackoverflow.com/questions/23696251/…. It was de working path for the build agent. We had it configured like this: "workFolder": "d:/_work" but the correct path must be: "workFolder": "d:\\_work"

Michael Vonck
  • 296
  • 2
  • 5