2

A MS teams channel has been configured to notify us after the last stage (prod deployment) in an azure devops pipeline has completed. However, there is a need to include SQL execution statistics like rows affected, duration etc. which I'm capturing in the logs in the release pipeline. Is there way to extract that single task log within a stage in the pipeline and post it to the teams channel?

Currently I'm offering stakeholders the ability to click on the link that takes them to the release within ADO and view the log that way. But I would like to just offer the log on the teams channel and save people time and confusion. I'm including a couple links as reference as to what I have been looking at, the official MS documentation and another is a stack overflow thread with a similar question, but for slack.

If it is done with this api, how would I capture the taskId? I'm not fully understanding how to do this:

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
Eric Swiggum
  • 97
  • 10
  • 1
    Are you using YAML, or Classic Release Pipeline? – Danielson Feb 01 '23 at 13:15
  • I think your question is answered in both answers here https://stackoverflow.com/questions/60184704/how-to-get-azure-devops-release-pipeline-deployment-logs-using-azure-devops-rest – Danielson Feb 01 '23 at 13:29
  • 1
    Exactly, I would try using following, though I don't have this tested: Install connector 'Incoming webhook' in MS Teams https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook?tabs=dotnet Depending on the behavior add as last step of production stage deployment a powershell script, that will get the log content of the specific task and trigger webhook with log in the body (the 'Incoming webhook' has limitation of 28 kb). If this will not work reliably, I'd create post deployment stage that will run only the the script. – Danielson Feb 02 '23 at 08:16
  • The bounty expired, I have resorted to just providing the URL for the log via a PS script task in the stage. Between this https://stackoverflow.com/questions/53982764/send-files-to-microsoft-teams-using-webhook and an intuitive way to get the taskid as described here https://developercommunity.visualstudio.com/t/detect-taskid-at-runtime-for-a-azure-devops-releas/538249 but, outside of that a developer showed me the ways to do this in Python. I might investigate that when I have more time. Consider this question UNRESOLVED. Thanks Microsoft;) – Eric Swiggum Feb 06 '23 at 22:42

0 Answers0