Sonar scan unable to complete after an hour

  • ALM used (Azure DevOps)
  • CI system used (Azure DevOps)
  • Scanner command used - Sonar plugin - SonarCloudAnalyze@3
  • Languages of the repository - C#

Scan stuck at “2/8 source files have been analyzed” step for an hour before ADO agent terminate due to agent timeout limit. Not seeing any additional info even though debug is enabled.

Are you able to check the actual issue from your logs? Scantime - 3:44 PM UTC+8 7/17

INFO: 2/8 source files have been analyzed
##[debug]Agent environment resources - Disk: C:\ Available 67692.94 MB out of 129481.95 MB, Memory: Used 2511.00 MB out of 8190.00 MB, CPU: Usage 2.00%
##[debug]Agent environment resources - Disk: C:\ Available 67692.94 MB out of 129481.95 MB, Memory: Used 2511.00 MB out of 8190.00 MB, CPU: Usage 3.00%
INFO: 2/8 source files have been analyzed
##[debug]Agent environment resources - Disk: C:\ Available 67688.94 MB out of 129481.95 MB, Memory: Used 2511.00 MB out of 8190.00 MB, CPU: Usage 4.00%
INFO: 2/8 source files have been analyzed
##[debug]Agent environment resources - Disk: C:\ Available 67688.94 MB out of 129481.95 MB, Memory: Used 2511.00 MB out of 8190.00 MB, CPU: Usage 3.00%
##[debug]Re-evaluate condition on job cancellation for step: 'Run Code Analysis'.
##[error]The Operation will be canceled. The next steps may not contain expected logs.
##[error]The operation was canceled.
##[debug]System.OperationCanceledException: The operation was canceled.
   at System.Threading.CancellationToken.ThrowOperationCanceledException()
   at Microsoft.VisualStudio.Services.Agent.Util.ProcessInvoker.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, InputQueue`1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, Boolean continueAfterCancelProcessTreeKillAttempt, CancellationToken cancellationToken) in D:\a\_work\1\s\src\Agent.Sdk\ProcessInvoker.cs:line 384
   at Microsoft.VisualStudio.Services.Agent.ProcessInvokerWrapper.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, InputQueue`1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, Boolean continueAfterCancelProcessTreeKillAttempt, CancellationToken cancellationToken) in D:\a\_work\1\s\src\Microsoft.VisualStudio.Services.Agent\ProcessInvoker.cs:line 329
   at Microsoft.VisualStudio.Services.Agent.Worker.Handlers.DefaultStepHost.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, Boolean inheritConsoleHandler, Boolean continueAfterCancelProcessTreeKillAttempt, TimeSpan sigintTimeout, TimeSpan sigtermTimeout, Boolean useGracefulShutdown, CancellationToken cancellationToken) in D:\a\_work\1\s\src\Agent.Worker\Handlers\StepHost.cs:line 85
   at Microsoft.VisualStudio.Services.Agent.Worker.Handlers.NodeHandler.RunAsync() in D:\a\_work\1\s\src\Agent.Worker\Handlers\NodeHandler.cs:line 267
   at Microsoft.VisualStudio.Services.Agent.Worker.TaskRunner.RunAsyncInternal() in D:\a\_work\1\s\src\Agent.Worker\TaskRunner.cs:line 447
   at Microsoft.VisualStudio.Services.Agent.Worker.TaskRunner.RunAsync() in D:\a\_work\1\s\src\Agent.Worker\TaskRunner.cs:line 76
   at Microsoft.VisualStudio.Services.Agent.Worker.StepsRunner.RunStepAsync(IStep step, CancellationToken jobCancellationToken) in D:\a\_work\1\s\src\Agent.Worker\StepsRunner.cs:line 264
Finishing: Run Code Analysis

Hey there.

Since these are scanner-side logs, we don’t have them!

What’s going on in the analysis immediately before you start seeing the message 2/8 source files have been analyzed?

Try setting sonar.verbose=true in the extraProperties block of your SonarQubePrepare task.