Azure DevOps task option publishCodeCoverageResults doesn't work with relative targetdir path
cremor opened this issue · comments
cremor commented
Describe the bug
It seems like there is an issue with the new task option publishCodeCoverageResults
and relative paths. If targetdir
is a relative path (like shown in the recommendation in the task's readme) the publishing fails.
To Reproduce
- Create a Azure DevOps build pipeline with a task like this:
- task: reportgenerator@5
displayName: 'Convert and publish code coverage report'
inputs:
reports: '$(Agent.TempDirectory)/**/coverage.opencover.xml'
targetdir: 'coveragereport'
publishCodeCoverageResults: true
- Run the pipeline. It will fail. (I've tested both 'ubuntu-latest' and 'windows-latest' agents, both failed.)
- Change the task option to:
targetdir: '$(Agent.TempDirectory)/coveragereport'
- Run the pipeline again. Now it works.
Log for the failed run:
2024-05-15T07:36:29.9133363Z ##[section]Starting: Convert and publish code coverage report
2024-05-15T07:36:29.9137543Z ==============================================================================
2024-05-15T07:36:29.9137666Z Task : ReportGenerator
2024-05-15T07:36:29.9137738Z Description : 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.
2024-05-15T07:36:29.9137957Z Version : 5.3.0
2024-05-15T07:36:29.9138015Z Author : Palmmedia
2024-05-15T07:36:29.9138103Z Help : [More Information](https://github.com/danielpalme/ReportGenerator)
2024-05-15T07:36:29.9138206Z ==============================================================================
2024-05-15T07:36:30.1262183Z [command]/opt/hostedtoolcache/dotnet/dotnet /home/vsts/work/_tasks/reportgenerator_be803a55-9253-4895-a525-be570d86f161/5.3.0/tools/net6.0/ReportGenerator.dll -reports:/home/vsts/work/_temp/**/coverage.opencover.xml -targetdir:coveragereport -reporttypes:HtmlInline_AzurePipelines;Cobertura -sourcedirs: -historydir: -plugins: -assemblyfilters:+* -classfilters:+* -filefilters:+* -verbosity:Info -title: -tag:20240515.9_#51817 -license:
2024-05-15T07:36:30.7248108Z 2024-05-15T07:36:30: File '/_/src/WebApi/obj/Release/net8.0/Riok.Mapperly/Riok.Mapperly.MapperGenerator/EntityVersionIdentifierMapper.g.cs' does not exist (any more).
2024-05-15T07:36:30.7275696Z 2024-05-15T07:36:30: File '/_/src/WebApi/obj/Release/net8.0/Riok.Mapperly/Riok.Mapperly.MapperGenerator/TodoItemMapper.g.cs' does not exist (any more).
2024-05-15T07:36:30.7361418Z 2024-05-15T07:36:30: File '/_/src/WebApi/obj/Release/net8.0/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs' does not exist (any more).
2024-05-15T07:36:30.7623487Z 2024-05-15T07:36:30: File '/_/src/WebApi/obj/Release/net8.0/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs' does not exist (any more).
2024-05-15T07:36:30.7729191Z 2024-05-15T07:36:30: Writing report file 'coveragereport/Cobertura.xml'
2024-05-15T07:36:30.7800073Z 2024-05-15T07:36:30: Writing report file 'coveragereport/index.html'
2024-05-15T07:36:30.8096534Z 2024-05-15T07:36:30: Report generation took 0.5 seconds
2024-05-15T07:36:30.8153176Z
2024-05-15T07:36:30.8222412Z Reading code coverage summary from 'coveragereport/Cobertura.xml'
2024-05-15T07:36:30.8232785Z ##[error]Unable to process command '##vso[codecoverage.publish codecoveragetool=Cobertura;summaryfile=coveragereport/Cobertura.xml;reportdirectory=coveragereport;]' successfully. Please reference documentation (http://go.microsoft.com/fwlink/?LinkId=817296)
2024-05-15T07:36:30.8250618Z ##[error]File 'coveragereport/Cobertura.xml' does not exist or is not accessible.
2024-05-15T07:36:30.8282751Z ##[section]Finishing: Convert and publish code coverage report
Daniel Palme commented
I will try to fix this in the next release. Until then please use an absolute path.
Daniel Palme commented
Relative paths are now supported.