ms-teams-notify
Notify a Microsoft Teams channel by sending a build notification including build artifact link to a specific Teams channel.
Features
- Sends a Teams Notification to specific channel.
- Uses AdaptiveCard format to provide a link to the latest build. A simple message format is included
- Customize your own AdaptiveCard via Templating
Model
You can access the informatoin of the following model (@see Context Root) in your AdaptiveCard Template.
The folllowin paragraphs illustrate the model in Typescript and as JSON Schema.
Typescript
export interface ContextModel {
$root: ContextRoot
}
export interface ContextRoot {
additionalInformation: string;
additionalImageSrc: string;
name: string;
photo: string;
artifactUrl: string;
message: string;
additionalHyperLink: string;
}
JSON Schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"$root": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"photo": {
"type": "string"
},
"message": {
"type": "string"
},
"artifactUrl": {
"type": "string"
},
"additionalHyperLink": {
"type": "string"
},
"additionalInf\normation": {
"type": "string"
},
"additionalImageSrc": {
"type": "string"
}
},
"required": [
"name",
"photo",
"message",
"artifactUrl",
"additionalHyperLink",
"additionalInf\normation",
"additionalImageSrc"
]
}
},
"required": [
"$root"
]
}
Default Message Teplate
{
"type":"message",
"attachments":[
{
"contentType":"application/vnd.microsoft.card.adaptive",
"contentUrl": null,
"content":
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.3",
"body": [
{
"type": "TextBlock",
"text": "**${name}**"
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "Image",
"url": "${photo}",
"size": "Small"
}
],
"width": "auto"
},
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"text": "${message}",
"wrap": true
}
],
"width": "stretch"
}
]
}
],
"actions": [
{
"type": "Action.OpenUrl",
"title": "Download Artifact",
"url": "${artifactUrl}"
}
]
}
}]
}
Usage
The following example demonstrates the usage of TeamsNotifier@1
in release pipeline:
steps:
- task: TeamsNotifier@1
displayName: Notifiy Microsoft Teams Channel
inputs:
teamsChannelName: 'FooBar'
teamsChannelWebhook: $(WebHookUri)
templatePayLoadFilePath: '$()' # optional, full path, json must encoded with UTF-8 without BOM
iconImageSrc: 'https://pbs.twimg.com/profile_images/3647943215/d7f12830b3c17a5a9e4afcc370e3a37e_400x400.jpeg' # optional
additionalHyperlink: 'http://example.com/' # optional
additionalInfo: 'Etaoin shrdlu'
additionalImageSrc: 'https://pbs.twimg.com/profile_images/3647943215/d7f12830b3c17a5a9e4afcc370e3a37e_400x400.jpeg' #optoinal