【发布时间】:2019-10-07 17:59:50
【问题描述】:
我一直在尝试从构建管道中检索自动化测试结果。 有没有人可以帮我弄清楚?
我让 VSTEST 作为默认值:
steps:
- task: VSTest@2
displayName: 'VsTest - testAssemblies'
inputs:
runOnlyImpactedTests: false
rerunFailedTests: false
此外,发布测试结果设置为默认值:
steps:
- task: PublishTestResults@2
displayName: 'Publish Test Results **/TEST-*.xml'
inputs:
testResultsFormat: VSTest
最后我试图在 slack 上发布测试结果(但我不知道如何获取我需要的数据)。
然后是 POST SLACK NOTIFICATION 的 yaml:
#Your build pipeline references an undefined variable named ‘date:yyyyMMdd’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references an undefined variable named ‘rev:.r’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
steps:
- task: kasunkodagoda.slack-notification.slack-notification-task.SlackNotification@5
displayName: 'Post Slack Notification'
inputs:
SlackApiToken: 'xoxp-I_HIDE_IT_BECAUSE_IT_IS_SECRET'
Channel: '#devops_ci'
Message: 'A new build is available $(date:yyyyMMdd)$(rev:.r)'
UseVariableForMessage: true
AuthorName: 'Continuous Integration'
AuthorLink: 'https://I_HIDE_IT_BECAUSE_IT_IS_SECRET.visualstudio.com/SHIVA/_build?definitionId=1'
PreText: 'Attachment Pre-Text'
Text: 'Attachment Text'
非常感谢。
【问题讨论】:
-
您有发布测试结果的任务吗?请更具体地说明您在做什么以及存在的问题(这可能是一次截图是可以的,除非您使用的是 YAML 构建)
-
@BradleyDotNET 我只是添加了一些信息,也许你可以给我一些提示。我试图通过发布测试结果来做到这一点,但我不能
-
感谢您添加。跟进问题。测试结果是否正确显示在构建摘要中并且没有松弛,或者没有收集任何结果?如果它只是松弛的集成,我不完全确定是否/如何让它显示测试结果(我们只显示最终构建状态)
-
@BradleyDotNET 感谢您的帮助,我刚刚用摘要的屏幕截图更新了帖子,并添加了用于帖子松弛通知的 yaml。问题是:如何从上一个任务中获取数据?最后,我想在 slack 上发布类似 number_of_test_ok/number_of_total_tests 的内容。我刚刚看到您更新了您的评论:如何显示最终构建状态?
-
我使用 DevOps webhook 构建 slack,我没有使用管道步骤。我不确定如何访问测试计数,我没有看到它的预定义变量,因此您可能需要一个自定义测试运行器任务来输出该信息
标签: c# .net azure-devops continuous-integration