I’m using SonarScanner for .NET to perform code quality analysis and to gather coverage data.
Currently both of the above processes including the begin
and end
steps are performed in a single CI job that takes quite a while (cumulative cost of building project, test project, running tests and Sonar scan overhead). This leaves me with 2 options:
- Wait for the single big job to complete to export the build output and reuse it in subsequent jobs
- Perform build step in a separate parallel job (quicker than the big job) and run other jobs that depend on the build output after it
I don’t like any of the above 2 options as I either have to:
- pay by having a CI workflow with slower feedback cycle
- pay by spending more CI minutes ($$$) by having to build the source code twice
My question is following - is it possible to split the SonarScanner for .NET execution into multiple jobs as follows:
- Job 1:
dotnet sonarscanner begin
+dotnet build
- Job 2:
<outputs of Job 1>
+dotnet test
+dotnet sonarscanner end
?
If that is possible, which system paths do I need to preserve between Job 1 and Job 2 so that the scan started by the first job can be completed by the second job?