20
votes

I am having trouble getting my code coverage reports to work, or rather, to get DevOps to pass my parameters correctly. If I download the build directory (zipped in the build), the ReportGenerator reports are available, but they don't get published. So I know that part is working at least. :)

However, when the publish step runs it creates new reports and uses those instead. My Yaml file is as follows:

## Generate Reports
- task: Palmmedia.reportgenerator.reportgenerator-build-release-task.reportgenerator@4
  displayName: Generate Code Coverage Reports
  inputs:
    reports: '**\coverage.cobertura.xml'
    targetdir: 'results'
    reporttypes: 'HTML;HtmlInline_AzurePipelines;Badges;Cobertura'
    assemblyfilters: '-*tests*'
    continueOnError: true


# Publish Code Coverage Reports
- task: PublishCodeCoverageResults@1
  displayName: Publish Code Coverage Results
  inputs:
    disable.coverage.autogenerate: true
    summaryFileLocation: $(Build.SourcesDirectory)\results\cobertura.xml
    reportDirectory: $(Build.SourcesDirectory)\results
    codecoverageTool: cobertura
    continueOnError: true

However, when I run in Debug, I get the following output:

##[debug]disable.coverage.autogenerate=undefined

I have tried the following options for passing this parameter:

disable.coverage.autogenerate: true
disable.coverage.autogenerate: 'true'
disable.coverage.autogenerate: 1

None of them have successfully passed anything to the task.

Without this flag set, the task overwrites the HTML reports generated by ReportGenerator and outputs the following:

##[warning]Ignoring coverage report directory with Html content as we are auto-generating Html content

I am working based upon the information pasted by Daniel Palme (author of ReportGenerator) here, as well as reading the actual code for the task here.

My source code is being open sourced, so if logs or more information help you provide an answer, it is all available here. A build with a good log is here. The Yaml file is here, and is called from the various other repositories in the project.

Any advice on how to get around this issue would be appreciated.

1

1 Answers

36
votes

Well, in standard operating procedure, get annoyed, write a long post on Stack Overflow, find a nugget somewhere, and solve your own problem.

It is not a parameter, but rather an environment variable that needs to be set. Adding the following to the start of the Yaml file takes care of it.

variables:
  disable.coverage.autogenerate: 'true'

Leaving this here to save the next person stuck on this problem days of trouble shooting. :/