danielpalme / ReportGenerator

ReportGenerator converts coverage reports generated by coverlet, OpenCover, dotCover, Visual Studio, NCover, Cobertura, JaCoCo, Clover, gcov or lcov into human readable reports in various formats.
https://reportgenerator.io
Apache License 2.0
2.56k stars 279 forks source link

I don't manage to get the final results exposed in Azure DevOps UI #637

Closed 12rambau closed 8 months ago

12rambau commented 8 months ago

I'm using this wonderful devOps extention to publish nicer coverage reports but I fail to display them in the interface of my pipeline.

I'm using the following job in my pipeline, that is the only one interacting with coverage so I removed the rest. it's running on an ubuntu-latest runner so nothing exotic here.

- job: coverage
        steps:
          - task: UsePythonVersion@0
            inputs:
              versionSpec: "3.9"
            displayName: Use Python 3.9
          - script: python -m pip install nox
            displayName: Install dependencies
          - script: nox -s ci-test -- "Coverage tests"
            displayName: Test with pytest
          - task: reportgenerator@5
            displayName: ReportGenerator
            inputs:
              reports: "coverage.xml"
              targetdir: "coveragereport"
              reporttypes: "HtmlInline_AzurePipelines;Cobertura"
          - task: PublishCodeCoverageResults@2
            displayName: Publish code coverage results
            inputs:
                  summaryFileLocation: "coverage.xml"
              summaryFileLocation: $(Build.SourcesDirectory)/coveragereport/Cobertura.xml
              reportDirectory: $(Build.SourcesDirectory)/coveragereport
              codecoverageTool: cobertura
            env:
              DISABLE_COVERAGE_AUTOGENERATE: "true"

But when my pipeline ends I got the following display in the devOps interface:

What should I change to display the html output instead ?

danielpalme commented 8 months ago

You have to change two things:

disable.coverage.autogenerate: 'true'

- task: PublishCodeCoverageResults@1
  displayName: 'Publish code coverage results'
  inputs:
    codeCoverageTool: Cobertura
    summaryFileLocation: '$(Build.SourcesDirectory)/coveragereport/Cobertura.xml'
    reportDirectory: '$(Build.SourcesDirectory)/coveragereport'

See also: https://github.com/danielpalme/ReportGenerator/wiki/Integration#attention

12rambau commented 8 months ago

wonderful it works.

I didn't clearly understand how to use the disable.coverage.autogenerate.variable but I used a scoped env var that has the same consequences:

- task: PublishCodeCoverageResults@1
  displayName: Publish code coverage results
  inputs:
    summaryFileLocation: $(Build.SourcesDirectory)/coveragereport/Cobertura.xml
    reportDirectory: $(Build.SourcesDirectory)/coveragereport
   codecoverageTool: cobertura
   env:
     DISABLE_COVERAGE_AUTOGENERATE: "true"