当尝试使用'ReportGenerator‘工具作为Azure devops YAML pipleine的一部分来创建报告时,尽管我在上一步中安装了该工具,但还是抛出了下面的错误。
- script: dotnet tool install --global dotnet-reportgenerator-globaltool --version 4.6.1
displayName: 'Install ReportGenerator tool'
continueOnError: true
- script: reportgenerator "-reports:$(Agent.TempDirectory)/**/*.cobertura.xml" "-targetdir:$(Build.SourcesDirectory)/coverlet/reports" -reporttypes:Cobertura;htmlInline
displayName: Generate code coverage report
continueOnError: true错误:未将'reportgenerator‘识别为内部或外部命令、可操作程序或批处理文件。##errorCmd.exe已退出,代码为“%1”。
添加日志安装步骤:脚本内容: dotnet工具Install dotnet- reportgenerator -globaltool --工具路径工具--版本4.6.1 ==========================启动命令Output =========================== "C:\windows\system32\cmd.exe“/D /E:ON /V:OFF /S /C "CALL "E:\Agent_work_temp\d9535a65-152b-4822-a4f2-7e58c11f2418.cmd"”您可以使用以下命令调用该工具:reportgenerator工具'dotnet-reportgenerator-globaltool‘(版本'4.6.1')已成功安装。完成:安装ReportGenerator工具
执行工具:脚本内容: reportgenerator "-reports:E:\Agent_work_temp/**/*.cobertura.xml“"-targetdir:E:\Agent_work\79\s/coverlet/reports”-reporttypes:Cobertura;无法将htmlInline ==========================启动命令输出=========================== "C:\windows\system32\cmd.exe“/D /E:ON /V:OFF /S /C "CALL reportgenerator”识别为内部或外部命令、可操作程序或批处理文件。##errorCmd.exe已退出,代码为“%1”。
发布于 2020-07-03 05:26:02
当你在Linux机器上尝试这样做时,会出现a known bug。安装报表生成器后,请尝试添加此附加步骤以更新路径:
- script: echo "##vso[task.prependpath]$HOME/.dotnet/tools"所以整个解决方案看起来是这样的:
- task: DotNetCoreCLI@2
displayName: Install ReportGenerator Global Tool
inputs:
command: custom
custom: tool
arguments: install dotnet-reportgenerator-globaltool -g
- script: echo "##vso[task.prependpath]$HOME/.dotnet/tools"
displayName: 'Update PATH'
- script: reportgenerator "-reports:$(Agent.TempDirectory)/**/*.cobertura.xml" "-targetdir:$(Build.SourcesDirectory)/coverlet/reports" -reporttypes:Cobertura;htmlInline
displayName: Generate code coverage report
continueOnError: true发布于 2020-07-03 17:53:51
下面的YAML文件可以完成这项工作:
- script: dotnet tool install --tool-path tools dotnet-reportgenerator-globaltool --version 4.6.1
displayName: 'Install ReportGenerator tool'
continueOnError: true
- script: ./tools/reportgenerator "-reports:$(Agent.TempDirectory)/**/*.cobertura.xml" "-targetdir:$(Build.SourcesDirectory)/coverlet/reports" "-reporttypes:Cobertura;HtmlInline"你也可以使用Azure DevOps扩展:
https://marketplace.visualstudio.com/items?itemName=Palmmedia.reportgenerator
用法:
- task: Palmmedia.reportgenerator.reportgenerator-build-release-task.reportgenerator@4
displayName: ReportGenerator
inputs:
reports: '$(Agent.TempDirectory)/**/*.cobertura.xml'
targetdir: '$(Build.SourcesDirectory)/coverlet/reports'
reporttypes: 'Cobertura;HtmlInline'发布于 2020-07-03 17:12:24
这是因为您使用的是自托管代理。在代理上安装新软件后,必须重新启动代理以使新功能显示在池中,以便可以运行构建。
只需转到代理计算机上的任务管理器并重新启动生成代理服务。
https://stackoverflow.com/questions/62705105
复制相似问题