1

我在 TFS/AZureDevopsServer-2019 中运行我的构建和发布管道,下面是 azure-pipeline.yml 中使用的 YAML

管道运行时不会生成分析

构建管道 在此处输入图像描述

我如何按照“ https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-test-results?view=azure-devops&tabs=trx%2Cyaml ”添加了以下任务在我的管道中

- task: Maven@3
  inputs:
    mavenPomFile: '$(System.DefaultWorkingDirectory)/maven/pom.xml'
    goals: package
    mavenAuthenticateFeed: true
    sonarQubeRunAnalysis: true
    publishJUnitResults: true    
    sqMavenPluginVersionChoice: 'latest'

- task: PublishTestResults@2
  inputs:
    testResultsFormat: 'JUnit' 
    searchFolder: '$(System.DefaultWorkingDirectory)'
    publishJUnitResults: true
    testResultsFiles: '**/surefire-reports/TEST-*.xml'
    codeCoverageToolOption: JaCoCo

管道结果

2021-03-30T17:11:52.9179560Z ##[warning]No test result files matching **/TEST-*.xml were found.

在此处输入图像描述

4

2 回答 2

2

错误消息表明没有与 **/TEST-*.xml 匹配的测试结果文件。您需要检查您的管道中是否有测试任务,并在运行测试任务后查看日志,以检查是否已生成测试文件。

此外,默认选项使用 JUnit 格式发布测试结果。在所有子目录中**/TEST-*.xml搜索名称以开头的所有 XML 文件。TEST-如果使用 VSTest 作为testRunner,则testResultsFiles选项应更改为**/TEST-*.trx.

于 2021-03-31T06:48:55.877 回答
0

如果有人正在使用部署在 Windows 机器上的代理,这里有一个提示。我建议不要指定$(System.DefaultWorkingDirectory)测试结果路径。测试运行器创建相对于当前工作目录的“测试结果”文件。例如,如果您正在运行 junit,那么您可以指定,代理在当前工作目录下--junit-directory /reports创建一个文件夹,文件将放在. 相反,指定有一些不良结果。/reports.xml/reports$(System.DefaultWorkingDirectory)/reports

于 2021-08-04T09:13:23.133 回答