1

I'm trying to send a detailed email-notification on test failure in azure pipeline build. I'm following the suggestion in this thread : How to send a detailed email to specific developer from Azure DevOps on failure of unit tests from a Build pipeline? I saw the example request as below

GET https://dev.azure.com/{organization}/{project}/_apis/test/Runs/{runId}/results/{testCaseResultId}?api-version=5.0

How can i get the value of 'runId' and 'testCaseResultId' ? Is there any environment variable that can use in my pipeline to automatically substitute their values ?

Can anyone suggest me a best way to use Result-Get?

Sruthi CP
  • 341
  • 3
  • 13
  • Hi SruthiChedath,Just checking to see if the information provided was helpful. If my reply helped or gave a right direction. Appreciate for marking it as an answer, which will also help others in the community. – PatrickLu-MSFT Nov 29 '19 at 09:26
  • 1
    @PatrickLu-MSFT sorry, i didn't get time to check it . Thank you for your respone and i'll check that solution when my current task is done. Thank you :) – Sruthi CP Nov 29 '19 at 09:50

1 Answers1

1

You are trying to get a test result for a test run by using this Rest API. Both runId and testCaseResultId Parameter are required.

However, you are trying to fetch it during a build/release pipeline. This API is not apply to your situation. Since the build is still running not completed. So you need to get it through build/release task log.

Releases - Get Task Log

We used to use the following API to get test results for the release,
GET https://{instance}/{project}/_apis/ResultDetailsByRelease?releaseId={RELEASE.RELEASEID}&releaseEnvId={RELEASE.ENVIRONMENTURID}

The test results included testRun ID or get failed tests only by using filter,
GET https://{instance}/{project}/_apis/ResultDetailsByRelease?releaseId={RELEASE.RELEASEID}&releaseEnvId=RELEASE.ENVIRONMENTURID}&%24filter=Outcome+eq+Failed

Similar with build --Timeline - Get

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62