Reputation: 1
Team,
Just checking if there is way to send an email of Maven TestNG report directly from Azure DevOps.
Upvotes: 0
Views: 1205
Reputation: 19361
if there is way to send an email of Maven TestNG report directly from Azure DevOps
For this issue,Azure DevOps does not support exporting tests results and reports with email. There is currently no out-of-the-box feature to achieve this .
As a workaround , you can write a custom script to get the test result and publish it using email and then later on you can call it from Azure devops pipeline task. You need to implement C# automation script with Azure pipeline.
To achieve this ,you need Results - Get rest api to get test result for a test run.
GET https://dev.azure.com/{organization}/{project}/_apis/test/Runs/{runId}/results/{testCaseResultId}?api-version=5.0
Sample response :
{
"id": 100000,
"project": {
"id": "afb2b648-1eaf-48d3-9522-43a23bdxxx",
"name": "Test03",
"url": "https://dev.azure.com/{org}/_apis/projects/{pro}"
},
"startedDate": "2019-10-02T07:55:42.663Z",
"completedDate": "2019-10-02T07:55:44.19Z",
"durationInMs": 1527.0,
"outcome": "Passed",
"revision": 1,
"state": "Completed",
"testCase": {
"name": "response is ok"
},
"testRun": {
"id": "12",
"name": "JUnit_TestResults_1524",
"url": "https://dev.azure.com/{org}/{pro}/_apis/test/Runs/12"
},
"lastUpdatedDate": "2019-10-02T07:56:40.21Z",
"priority": 0,
"build": {
"id": "1524",
"name": "1524",
"url": "https://dev.azure.com/{org}/_apis/build/Builds/1524"
},
"createdDate": "2019-10-02T07:56:40.21Z",
"url": "https://dev.azure.com/{org}/{pro}/_apis/test/Runs/12/Results/100000",
"failureType": "None",
"automatedTestStorage": "TestCollection",
"automatedTestType": "JUnit",
"testCaseTitle": "response is ok",
"customFields": [],
"testCaseReferenceId": 1476072,
"runBy": {
"displayName": "xxx",
"url": "https://spsprodea1.vssps.visualstudio.com/Ac3616973-xxxx-4b09-aaf7-2917c99fxxx4/_apis/Identities/9f723013-xxxx-64e5-xxxx-6e3eb2f9d353",
"_links": {
"avatar": {
"href": "https://dev.azure.com/{org}/_apis/GraphProfile/MemberAvatars/msa.OWY3MjMwMTMtYTMzMi03NGU1LWFlYTktNmUzZWIyZjlkMzUz"
}
},
"id": "9f723013-a332-64e5-aea9-6xxxxx9d353",
"uniqueName": "[email protected]",
"imageUrl": "https://dev.azure.com/{org}/_apis/GraphProfile/MemberAvatars/msa.OWYxxxxxYTMzMi03NGU1LWFlYTktNmUzZWIyZjlkMzUz",
"descriptor": "msa.OWY3MjMwMTMtYTMzMi03NGU1LWFlYTktNmUzZWIyZjlkMzUz"
},
"lastUpdatedBy": {
"displayName": "Project Collection Build Service (xxxx)",
"url": "https://spsprodea1.vssps.visualstudio.com/Ac3616973-xxxx-4b09-aaf7-2917c99faca4/_apis/Identities/3f8619f8-3c32-462a-xxx-f41dbdd15700",
"_links": {
"avatar": {
"href": "https://dev.azure.com/{org}/_apis/GraphProfile/MemberAvatars/svc.YzM2MTY5NzMtOGIxZS00YjA5LWFhZjctMjkxN2M5OWZhY2E0OkJ1aWxkOjA5MzNlOGIyLWY1xxxxx5ZTllLWNlMzAzYjA1ZWE1OQ"
}
},
"id": "3f8619f8-3c32-462a-a0f0-f41dbdd15700",
"uniqueName": "Build\\0933e8b2-f504-4b7e-9e9e-ce303b05ea59",
"imageUrl": "https://dev.azure.com/{org}/_apis/GraphProfile/MemberAvatars/svc.YzM2MTY5NzMtOGIxZS00YjA5LWFhZjctMjkxN2M5OWZhY2E0OkJ1aWxkOjA5MzNlOGIyLWY1MDQtNGI3ZS05ZTllxxxxxAzYjA1ZWE1OQ",
"descriptor": "svc.YzM2MTY5NzMtOGIxZS00YjA5LWFhZjctMjkxN2M5OWZhY2E0OkxxxxMzNlOGIyLWY1MDQtNGI3ZS05ZTllLWNlMzAzYjA1ZWE1OQ"
},
"automatedTestName": "response is ok"
}
On how to send E-mail using C#, you can refer to this case.
The above is a challenging approach,you could also choose to add your request for this feature on our UserVoice site, which is our main forum for product suggestions. You can comment and vote it there. Our PM and Product Group are reviewing these suggestion regularly and considering take it as plan.
Upvotes: 1