Remove hardcoding of my test room
Docs and cleanups
This ScriptRunner for Jira script lets your Jira send event updates to a Google Chat (https://chat.google.com) room.
The chat room is notified by webhook. In this implementation the webhook is stored per-issue in a custom field. This means that chat notification needs to be explicitly configured per-issue. Feel free to modify the code (getWebhookUrl
) to just return a static webhook URL for all issues.
Assuming you have ScriptRunner for Jira installed:
WEBHOOK_CHAT_CUSTOMFIELD_ID
value to the ID of your field.If it doesn't work, check the ScriptRunner listener history, where you can see any failures in the logs, or HTTP failure messages returned from Google.
I initially was posting GChat messages using the card format, which seems (at first) ideal for key-value pairs. However in practice the card format doesn't work: horizontal width is clipped to about 5cm, and there is no way to format blockquoted text. So I switched to the basic format, and have converted Jira wiki markup to GChat markup as far as possible.
As for future work, it would be nice if we could @mention people like the assignee. That would require looking up GChat user IDs via an authenticated REST call, then persisting the username -> GChatUserID mappings, perhaps using ActiveObjects, so that it is cached across events.
Another nice enhancement would be to set the webhook per project, rather than per issue. This would allow the 'Issue Created' events to be reported. This could be implemented using the Enhanced Project Properties plugin (see groovy code example).