2

We're using Azure DevOps to run a nightly build that checks our tests results. Our tests are decorated with Owner attribute (MSTest) of the test's owner name.

What is the simplest way to auto send email to the owner of the failing tests as part of the nightly run?

Can this functionality be achieved by using some built-in feature of Azure DevOps? If not, which custom flow can be integrated to the nightly build to achieve this?

BornToCode
  • 9,495
  • 9
  • 66
  • 83

1 Answers1

2

There is no such build-in feature in Azure DevOps for now.

Please take a look at similar question here: How to send a detailed email to specific developer from Azure DevOps on failure of unit tests from a Build pipeline?


As workaround, we could use a powershell script to get test results with REST API then send emails:

To get test results with RESI API Releases - Get Task Log:

GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}/environments/{environmentId}/deployPhases/{releaseDeployPhaseId}/tasks/{taskId}/logs?api-version=5.0-preview.2

Then use powershell scripts to read the details of the test result file (.trx) and create a formatted email message to sent to the defined recipients:

You could check this thread Send Test Result Email After Running Automated Tests with Release Management for some details.

There is also an Email Report Extension could handle e-mail related things in pipeline.

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • Where can I find the Resp API sample in the link you provided in the comment? I only see use of the extension? – BornToCode Nov 25 '20 at 19:52
  • 1
    @BornToCode Sorry for the wrong link. **1.** If the user manually run the test, you could check this link:https://stackoverflow.com/questions/62825065/how-to-get-the-unit-test-results-in-variables-in-azure-devops-pipelines **2.** If you run the test in the build.The test result of the build is stored in test runs, so you need to get the test run of the build first and then retrieve the test result from the test run. Detail sample please refer : https://stackoverflow.com/questions/39373499/how-to-get-unit-test-results-using-tfs-rest-api Hope it helps. – PatrickLu-MSFT Nov 26 '20 at 02:23