appveyor / ci

AppVeyor community support repository
https://www.appveyor.com
344 stars 66 forks source link

Add Google Chat to Notification Providers #2581

Open scrthq opened 6 years ago

scrthq commented 6 years ago

Google Chat (aka the new version of Hangouts) supports Webhooks and card format messages. I've tested adding as a custom Webhook with the following custom body and it works great for webhook notifications to Google Chat.

{
    "text": "<{{buildUrl}}|[{{projectName}}] Build {{buildVersion}} {{status}}>\nCommit <{{commitUrl}}|{{commitId}}> on Branch *{{branch}}* by *{{commitAuthor}}* on {{commitDate}}:\n_{{commitMessage}}_",
    "fallbackText": "[AppVeyor CI] Build {{status}}: {{projectName}} {{buildVersion}}"
}

The only thing AppVeyor users would need to configure is the Webhook for the Space they want to post the messages in. Directions for adding Webhooks in Google Chat can be found here: https://developers.google.com/hangouts/chat/how-tos/webhooks

Appearance in Google Chat:

image

Alternative body displaying commit message wrapped in code block:

{
    "text": "<{{buildUrl}}|[{{projectName}}] Build {{buildVersion}} {{status}}>\nCommit <{{commitUrl}}|{{commitId}}> on Branch *{{branch}}* by *{{commitAuthor}}* on {{commitDate}}:\n```\n{{commitMessage}}\n```",
    "fallbackText": "[AppVeyor CI] Build {{status}}: {{projectName}} {{buildVersion}}"
}

Appearance with this body:

image

IlyaFinkelshteyn commented 6 years ago

Do I understand correctly that adding AppVeyor built-in webhook notification with custom body is working approach for now?

scrthq commented 6 years ago

@IlyaFinkelshteyn Your understanding is correct; it's working without issue using the custom body with the built-in webhook notification. I'm pretty invested in the Google Chat API, so building the custom body wasn't too difficult for me, but having it as a built-in notification option (similar to Slack) would enable others who want plug-and-play notification setup for Google Chat to do just that as well.