Post a Message to Slack

This post-function/listener allows you to send a personalized custom message to either your HipChat or your Slack room.

There are bindings for the issue and the event object so that you can fetch the information pertinent to your event.

For example - you can choose to listen to Issue Resolved Event and have a message that outputs the resolution and the user that resolved the issue.

"Issue $issue resolved with resolution <% out << issue.resolution?.name %>. by <% out << event.getUser() %>"


In this case, the configuration is slightly more complicated. You need a Slack app with an access token.

This is a common feature for ScriptRunner products. It is found in Slack Connection (SR4J), .Post a Message to Slack v6.21.0 (SR4C), .Post a Message to Slack v6.21.0 (SR4BiB). If you make updates to this file, please check with the Project Manager and Tech Writer for those teams to coordinate efforts.

String templating in groovy

There are two variables available for you to use in your template, "issue" and "event". This last one is only available if you configure this feature as a listener.

Check the documentation about constructing your string template for the last field of the form:

As a summary, in order to call a property, you can call it with the name

"Your issue $issue has been updated."

But you can do more complex calls to your object by using the<% %> notation:

"Your Issue $issue was updated by <% out << event.getUser() %> on <% out << event.getTime() %>."

On this page