Azure DevOps - 在测试结果发布后发送电子邮件通知

Azure DevOps - send email notification after test results have been published

我们有一个夜间安排的管道,运行s 测试并将结果发布到测试 运行。我们可以看到 url 到测试 运行,因为这是由 PublishTestResults@2 任务生成的。我想通过将 devops link 的一组用户通过电子邮件发送给测试 运行.

来扩展此功能

发布任务当前的样子如下:

steps:
  # Publish test results (to show the test details in JUnit format)
  - task: PublishTestResults@2
    displayName: 'Publish test results'
    inputs:
      testResultsFormat: 'JUnit'
      testResultsFiles: '*.xml'
      searchFolder: '$(Build.SourcesDirectory)/cypress/reports/junit'
      mergeTestResults: true
      testRunTitle: 'Publish Test Results'
    condition: succeededOrFailed()
    continueOnError: true

是否有推荐的方法来执行此操作?

选项 1:通知

如果你只需要一个 link 到管道 运行 本身,你可以配置一个 notification.

选项 2:电子邮件报告扩展

如果您想要比通知提供更多的控制权,Email Report Extension 来自 Microsoft DevLabs 的生成(可自定义的)报告将发送到包含以下内容的收件人列表:

  • Overall Test Summary : This info mirrors the Test Tab in the Pipeline.
  • Test Run Summary: Information about individual test runs happened in the Pipeline if any.
  • Test Failures: Shows Test Failures, their stack traces (Configurable in the Task Input) and associated workitems.
  • Commits/Changeset Information
  • Phases/Environments Information
  • Task information: Task(s) that ran in the pipeline - Name, Duration and any error logs if failed.

您将需要提供用于发送电子邮件的 smtp 服务器的凭据

选项 3:其他分机

Azure DevOps a number of 3rd party email sending extensions

选项 4:自定义脚本

当然也可以选择创建一个 bash/powershell 脚本来发送电子邮件,这里是一个简单的 Powershell 示例: