Report coverage from multiple vsts agents


We have this setup:

  • code in github with pr and ci integration in vsts
  • building a .net web api with msbuild on a job, in a hosted vsts agent
  • the build artifacts are then downloaded (in the same pipeline) in 5 different self hosted vsts agents
  • we deploy locally the artifacts and run integration tests with coverage enabled

We need SonarCloud integration.
It is our understanding that we should use the vsts tasks to analyze the code and report coverage like this:

  • prepare and specify the coverage files
  • build
  • run analysis

In our context, in order to accommodate both our existing workflow and the SonarCloud tasks what we did was to add a final vsts job, that waits for all the test agents to finish and publish the coverage as artifacts; then we collect on the final jobs all coverage file, run prepare, build (again) and publish.

It is working, but recompiling adds unnecessary time to our builds (especially PRs). This is at least 10 minutes.

ideally we would maybe run the SonarCloud analysis on the first step , and then, at the end, we would just update the analysis with code coverage and test results.

Is this possible ? Is there another way to minimize the build/analyze/publish time ?

Thank you very much,


Unfortunately, this is not supported yet, the way you achieve it is the best for now.

What would be the best and easiest way to do that for you ?



I think the easiest way would be to have:

  • the first job would prepare code analysis, build the solution, report the code analysis
  • then we would have x jobs run the tests, generate the code coverage , and report the coverage to SonarCloud

If necessary , before all jobs we could maybe invoke something that would mark the start of an analysis session, then , after everything is finished, mark the session as finished.

This would be ok for us, but on the other hand, any solution that does not require a rebuild, is fine.

In the mean time, we were thinking that maybe we could:

  • run the prepare and build on the first agent ; but do not run the analysis
  • collect the .sonar folder and other required files as an artifact
  • run the tests , collect the coverage files and publish as an artifact
  • download all artifacts on a different agent; that is the .sonar folder and coverage files
  • fix paths in the .sonar files
  • run the analysis step that would publish to sonarcloud

The last solution of course is not something we actually want to do, as it is clearly very hard to maintain; but if we have long build times, I guess we will try it.

What do you think ?

Thank you,


Yes i think the simplest way to do that would be that multiple jobs, if their are linked by something, could have the possibility to upload their own analysis, which will be appended to a branch or a PR.

We’ll keep that in mind for a future thinking on releasing new features.

Thank you !


Ok, that is great.

But for now , we would like to manage this as best as we can .
What do you think about our workaround. Could it work, would you have some suggestions ?

Thank you,