Search code examples
azure-devopscode-coverageazure-pipelines

Control code coverage attachments in Azure DevOps


In a multi-stage, yaml configured CI pipeline that builds in Windows and Linux via matrix strategy I'm generating:

  • A .cobertura.xml file in Linux os, used to produce an aggregated report via ReportsGenerator that is accesible from coverage tab in AzureDevops. I'm explicitly using PublishCodeCoverageResults in this os.

  • A .coverage file in Windows os, to feed SonarCloud with coverage data. I'm not using PublishCodeCoverageResults in this os.

My issue is that .coverage file overrides the expected report in coverage tab, allowing me to download it rather than seeing the report. How can I avoid that? Is there any way to get rid of that attachment to properly show the report?


If I don't run the Windows part, the report is shown as expected.

If I do it, I get this rather than the report.

I've tried removing .coverage files at the end of the pipeline, but the 'attachment' in coverage tab stays there.


Solution

  • Answered here:

    This is not a bug and the behavior is as designed as the .coverage report is given precedence over other reports.

    My guidance would be to stop publishing the test run as part of the dotnet task in windows. There is an option to do so.

    Copy the trx and coverage files out to separate locations. Upload the trx file using the publish test results task but make sure the coverage file is not available for this publish.