SonarCloudAnalyze@1 when executed by different agent job to that of SonarCloudPrepare@1 in azure devops fails

SonarCloudAnalyze@1 task when executed by different agent job to that of SonarCloudPrepare@1 in azure devops fails with the following error

##[error][SQ] The ‘Prepare Analysis Configuration’ task was not executed prior to this task

As a workaround executing on the same agent solves it for now, but my ci runs takes 4X time than that of running the dotnet test in separate job agent.

here is insight to my pipeline tasks in sequence,
[Job-1]
SonarCloudPrepare@1

[Job-2]
DotNetCoreCLI@2 - restore
DotNetCoreCLI@2 - build
DotNetCoreCLI@2 - test (CoverletOutputFormat=opencover)
publish open cover artifact
download published artifact

[Job-3]
SonarCloudAnalyze@1
SonarCloudPublish@1

consolidating all into one job works.

Appreciate your suggestions.

Hi, and welcome to the community :slight_smile:

I’m afraid this isn’t possible at the moment. We are exploring ways in which build and test jobs could be run in parallel that might help your situation, however the Prepare task will always need to be run first and the Publish at the end once the build has completed and coverage file produced. The analysis is actually carried out by Roslyn during the build so the sequence is important. Hope that helps.

Tom

Hi @Tom_Howlett , Thank you for swift response.
I understand it has to be in sequence.
Any suggestions that I could take to reduce the time taken with all being on the same agent.

No problem, have a look at this guide. One good place to start regarding the test project might be:

dotnet build followed by dotnet test

dotnet test does a full build before running the tests. So if your pipeline executes dotnet build and then dotnet test , the build will be done twice, thus the analysis will be done twice.
Solution : run dotnet test --no-build , reusing the binaries from the build.

Hope that helps

Tom

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.