I am trying to find a way to export Azure Release Pipeline Automated Results to Teams
I currently use the Azure Pipelines plug in on teams however as I have the tests run on many devices and have two pipelines for web and mobile which means i'm getting about 20+ notifications a day which isn't very readable.
I wonder if anyone else had a similar issue and found a way round it? Possibly just getting 1 message per pipeline which included each stage and if it passed/failed?
Thanks!
As you're looking to send a custom message to Teams I would advice you to use the webhook functionality in Teams. Microsoft has some good documentation on creating webhooks and formatting the message for it. In good SO tradition, here are the steps:
Now you need to format and send a message to the webhook. I'll show you using powershell which is an easy way to add a custom task in your pipeline:
# First set some useful variables and define your messagecard
$header = "Test results"
$prefix = "[In Progress]"
$themeColor = "#0000FF"
$img = "https://cdn.you.want.to.use.com/it/image.png"
$teamsMessage = @{
"@type" = "MessageCard"
"@context" = "http://schema.org/extensions"
"themeColor" = $themeColor
"summary" = "$prefix $header"
sections = @(
@{
activityTitle = "$prefix $header"
activitySubtitle = "your subtitle"
activityImage = $img
},
@{
facts = @(
@{
name = 'Pipeline'
value = "[$definition]($definitionUrl)"
},
@{
name = 'Run'
value = "[$buildId]($BuildUrl)"
}
)
}
)
}
# Second, send the message to teams
# Convert message to json
$jsonObject = (ConvertTo-Json $teamsMessage -Depth 100)
# Log het jsonObject
$jsonObject | Out-Host
# Send teams message
$response = Invoke-RestMethod -Method POST -ContentType 'Application/Json' -Body $jsonObject -Uri $webhookUrl
if ($response -ne 1) {
Write-Warning "Response: $response"
Write-Host "##vso[task.complete result=SucceededWithIssues;]"
}