3

We have a nightly scheduled pipeline that runs tests and publishes the results to a test run. We can see the the url to the test run as this is generated by the PublishTestResults@2 task. I'd like to extend this functionality by emailing a set of users the devops link to the test run.

Here's how the publish task currently looks:

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

Are there any recommended approaches to doing this?

dubs
  • 6,511
  • 4
  • 19
  • 35
  • Have you looked into notifications? That might be a simple approach if you don't need super granular configuration options, you can for example send an email on completion of certain builds: https://learn.microsoft.com/en-us/azure/devops/notifications/about-notifications – danielorn Feb 13 '21 at 19:47
  • Hi @danielorn, yip I have looked into notifications, but I don't know how I can capture the url for the test run. To me using notifications is a bit 'late' in the process which was why I was thinking of an additional step inside the pipeline. I'll read up on the link you sent me, you never know, perhaps I could find something useful there - thanks. – dubs Feb 13 '21 at 20:37
  • Ok, I understand, with the requirement of sending a link to the url for the test the notifications are probably not gonna cut it, what you will get is typically a link to the pipeline run itself. To have full control you are better off adding a task in the pipeline that ends the email. – danielorn Feb 13 '21 at 20:45
  • @dubs Is there any update about this ticket? if the answer could solve this issue, you can consider accepting it as answer. – Kevin Lu-MSFT Feb 17 '21 at 06:38

1 Answers1

10

Option 1: Notifications

If you just need a link to the pipeline run itself, you can configure a notification.

Option 2: Email Report Extension

If you want more control than notifications offer the Email Report Extension from Microsoft DevLabs generates (a customizable) report sent to a list of recipients that contains:

  • 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.

You will need to provide credentials for the smtp server the email should be sent through

Option 3: Other extension

There is a number of 3rd party email sending extensions for Azure DevOps,

Option 4: Custom script

There is of course also the option to create a bash/powershell script to send the email, here is a simple Powershell Example: How to send email with PowerShell

danielorn
  • 5,254
  • 1
  • 18
  • 31