New version of Publish Code Coverage Results task

Bohdan Janousek

We’ve introduced a new V2 version of the publish code coverage results task (known as PCCR) in Azure Pipelines recently. The main benefit of the V2 task is the support for more formats of the code coverage results and therefore more programming languages than the V1 task, which was limited to Cobertura and JaCoCo formats only. You can see more details for the V2 task in our public documentation.

The V2 task was made compatible with the build quality check task (known as BQC) in version 2.231.0. Any customer using build quality check can safely migrate from the V1 task to the V2 task version 2.231.0 or later.

While we don’t have any immediate plans for deprecating the V1 task, we will stop improving the V1 task and continue to address only critical issues. All our efforts to add new features will be directed towards the V2 task. Now we are adding support for two additional code coverage result formats (.coverage and .covx) to the V2 task. These new formats will be supported in version 2.233.0 that will be made available to anyone on Azure DevOps Service in February 2024. Therefore, we highly recommend our customers to stop using the V1 task and to migrate to the V2 task. Use of the V2 task will ensure you can use an extended list of file formats and programming languages and will be able to leverage new ones as they get added in the future.

The V2 task is available to anyone on Azure DevOps Service or Azure DevOps Server 2022 and later.

Phase I – User opt-in

Users of either Azure DevOps Service or Azure DevOps Server 2022 and later should migrate all their publish code coverage results V1 tasks to the V2 task. The V2 task provides additional features against the V1 task while maintaining all the features of the V1.

Users are encouraged to replace their V1 tasks with the V2 tasks.

Phase II – Warning

Late February 2024, we will start to warn users who are using, or will try to use, the publish code coverage results V1 task. Specifically, we’ll do the following:

  • Add warning to the pipeline log file if that pipeline runs the publish code coverage results V1 task.
  • Show a warning to pipeline authors when adding the publish code coverage results V1 task.

The warning in both cases will have the link to this blog post and will state:

“New V2 version of task publishing code coverage results is available to all our customers now. We highly recommend to stop using the V1 version and migrate to V2 version (https://learn.microsoft.com/azure/devops/pipelines/tasks/reference/publish-code-coverage-results-v2). For more details see https://devblogs.microsoft.com/devops/new-pccr-task.”

Q&A

Q: I’m using Azure DevOps Server version earlier than 2022. Does this apply to me too?
A: No, it does not. Nonetheless, when upgrading to Azure DevOps Server 2022 and later or migrating to Azure DevOps Service, you should consider using the more feature rich V2 version of the publish code coverage results task.

Q: I’m using Azure DevOps Server version 2022. What will happen to me?
A: In a future version of the Azure DevOps Server, we will also remove the V1 version of the publish code coverage results task. There will be a transitioning period where the V1 version will still run. During the transition period you’ll need to move from the V1 version to the V2 version, as when the transition period ends the V1 version will be removed and any pipeline containing that task will fail.

Q: What do I need to add to the YAML pipeline definition to use the V2 task?
A: For details on configuration see the documentation for the V2 task here ( https://learn.microsoft.com/azure/devops/pipelines/tasks/reference/publish-code-coverage-results-v2) .

Q: Will there be any automatic conversion from V1 to V2 tasks done or will there be any script provided to handle the migration?
A: No, there will be neither automatic conversion of the pipelines to run V2 task instead of V1 nor any script provided to do such conversion.

25 comments

Discussion is closed. Login to edit/delete existing comments.

  • David Lawton 4

    The new task is generating summary page as well as individual HTML pages for each of my modules, for which I need to see line coverage. These are all available as artifacts linked to the build

    However, from the summary page in “Code Coverage”, there is no link between my module names in the summary and the individual module HTML reports. It is, at present, a retrograde step. Do you have plans to address this?

    • Bohdan JanousekMicrosoft employee 0

      Thanks for raising this. To view the actual source code of the file with lines being marked as covered or not is something we may support in the future. It is not in place now for the V2 task yet as that is not compatible with additional features supported by the V2 task. For example, the build quality checks done on individual folders.

      • Mee, Laurence (Reigate) 10

        It doesn’t seem to be a step forward to bring out a new version of a tool that does considerably less than the version it is meant to replace. As it stands, it is fairly useless apart from a simple measure of coverage. We can’t change to V2 whilst the display is limited to a summary and the line coverage is not present. It seems premature to try to persuade people to downgrade to V2.

        • Gioacchino Piazzolla 2

          I’m agree with Laurence. This should be still possible also in the V2.

          • anonymous 1

            this comment has been deleted.

  • Matt Olson 5

    How do we see reports generated by ReportGenerator using this new task?

    EDIT: It looks like V2 doesn’t support report generator reports and you need to use V1 until it is fixed. See here: https://github.com/danielpalme/ReportGenerator/issues/646

  • Andrei IlnitskiiMicrosoft employee 3

    With v1 my Code Coverage page shows a lot of data: https://dev.azure.com/msdata/Babylon/_build/results?buildId=121313941&view=codecoverage-tab
    But with v2 it’s very limited: https://dev.azure.com/msdata/Babylon/_build/results?buildId=121314637&view=codecoverage-tab

    … It could be related to ReportGenerator not being supported in v2. I really like what v1 gives: not just numbers but also source code highlighted.

    …Looks like previous comments are also about that.

    • Bohdan JanousekMicrosoft employee 0

      Yes, the current gap between V1 and V2 (missing line and branch based coverage) is because the V2 does not use the report generator internally. There were issues with report generator for larger repositories and that is one of the reasons to move away from that.

      • Jeff Sharp (EXT) 0

        No branch coverage means my clients will not use this new task. The V2 task should have remained in preview until it got feature parity with its predecessor. Slapping a strongly-worded warning in everyone’s builds was the wrong move.

        Did anyone try collaborating with the ReportGenerator guy to resolve the issues with large repositories?

  • Lucas Partridge 6

    I tried upgrading to v2 today (2.236.1) in Azure DevOps but faced 2 issues – no results on the Code Coverage tab of the build pipeline page; and the code coverage report wasn’t uploaded to the build’s published artifacts. These are both despite the absence of any warnings or errors in the task’s output logs. I see similar issues have been raised at https://github.com/microsoft/azure-pipelines-tasks/issues/18782 and https://github.com/microsoft/azure-pipelines-tasks/issues/19547.

    So I’m reverting to v1 and will put up with the annoying migration warning until v2 has been fixed.

  • Michael Cooke 4

    My organisation uses the Build Quality Checks task based on branch coverage so branch coverage is what we are really interested in seeing on the report. Using version 1 of this build task combined with ReportGenerator task gave us a report that showed line coverage and branch coverage but with version 2 we now just have line coverage. Is there any plan to include branch coverage in the report or better yet add a setting in the task to select which type(s) of coverage to display?

    • Bohdan JanousekMicrosoft employee 1

      We do plan to look into supporting the branch based code coverage in the V2 task.

  • Matthew Hull 5

    The v1 task automatically ran ReportGenerator under the hood and would upload reports (which appeared on the code coverage tab) that not only showed line/branch coverage but also let you navigate through the files, see covered lines and more. (We don’t run report generator manually, so it has to be done by Azure DevOps for us).

    V2 does not do this. The report is very basic and lacks a ton of functionality which we relied on as a team. We will need to continue using the V1 task as this is a regression for us.

    Are there any plans to start supporting this? If the V1 task is not going to be completely removed, is there a way to get an option/knob to suppress the warning similar to how one was added for other tasks as well as the node task deprecation? The warning is essentially noise as it’s pointing to something that is absolutely not an option for us at this time.

    • Bohdan JanousekMicrosoft employee 0

      We do expect to close the gap between the V2 and V1. Mainly the line based coverage. The V2 task is not using the report generator and there are no plans to rely on that. Nonetheless there still may be benefit on the V2 task – code coverage for folders and there can be set build quality checks to ensure respective folders will meet the requirements that may differ from the overall coverage required.

      • anonymous 0

        this comment has been deleted.

    • Jeff Sharp (EXT) 0

      There does not seem to be any way of squelching the warning.

      See here:

      // Log warning for PCCR V1 task deprecation
      tl.warning(tl.loc('V1TaskDeprecationNotice'));
  • Martijn den Hoedt 1

    The documentation on https://learn.microsoft.com/en-us/azure/devops/pipelines/test/review-code-coverage-results?view=azure-devops seems outdated and has a lot of broken link.

    Also you make it seem the upgrade is trivial while it’s unclear how to set up with the new task version. I used to get the line coverage report while using:

    - script: dotnet tool install --global dotnet-reportgenerator-globaltool
      displayName: Install ReportGenerator tool
    
    - script: >-
        reportgenerator
        -reports:$(Agent.TempDirectory)/**/coverage.cobertura.xml
        -targetdir:$(Build.SourcesDirectory)/coverlet/reports
        -assemblyfilters:+*;-*.*.Tests
        -reporttypes:"Cobertura"
      displayName: 'Generate Coverage Reports'
    
    - task: PublishCodeCoverageResults@1
      displayName: Publish Coverage Reports
      inputs:
        codeCoverageTool: Cobertura
        summaryFileLocation: $(Build.SourcesDirectory)/coverlet/reports/Cobertura.xml
  • Gioacchino Piazzolla 2

    Feels strange to note that the main concern of the “Publish Code Coverage Results” is not related to the publication of the code coverage results, but to secondary things such as “Build quality check” task. Why this drawback? The V1 version seems reasonable better by far

  • Tom Sollas 9

    The lack of branch coverage and lack of showing the covered lines in source code means this V2 task is essentially useless. V1 should not be marked deprecated until V2 has at least the same functionality. Staying on V1 for now, as V2 is pretty useless to me for the moment.

    • Alexander Batishchev 3

      +1. The new task is one step forward, two steps back.

    • Rigg, Bruce (Reigate) 4

      Completely agree, V2 seems to be totally useless and the V1 deprecation warnings are irritating.

  • Alexander Batishchev 3

    @Bohdan Janousek, what’s the plan for v3 or at least 2.1 which won’t require .NET Core 2.1 which saw its end of live in August 2021?

    We highly recommend to stop using the V1 version and migrate to V2 version

    How come do you recommend migrating to something which has a hard but long-time deprecated version dependency like that?

Feedback usabilla icon