Send Custom Notification to Slack


Add custom slack notifications on a workflow post function, or as a custom listener after an issue event. Configure the message content and direct the message to a room or specific user.


As a project manager, I want to keep track of all changes to my watched issues. I can use this script to send me a slack notification when one of my watched issues is transitioned.

Good to Know


Jira Jira (7.7 - 8.6)

import com.atlassian.jira.component.ComponentAccessor import import import import // You have to create a webhook first: // // Your webhook is related to one channel or user to which you will be able to send messages // Once you have your webhook, split it into it's base URL and it's URL path final webhookBase = '' final webhookPath = '/services/XYZ/XYZ/XYZ' def jiraBaseUrl = ComponentAccessor.applicationProperties.getString(APKeys.JIRA_BASEURL) // We have to convert this GString into String explicitly here def message = "New issue created in project $ : " as String def body = [ text : message, attachments: [ [ color : '#f2c744', blocks: [ [ type : 'section', fields: [ [ type: 'mrkdwn', text: "*Summary*\n$issue.summary" as String ], [ type: 'mrkdwn', text: "*Reporter*\n$issue.reporter.displayName" as String ], [ type: 'mrkdwn', text: "*Description*\n$issue.description" as String ] ] ] ] ] ] ] def response = new RESTClient(webhookBase).post( path: webhookPath, contentType: ContentType.HTML, body: body, requestContentType: ContentType.JSON ) as HttpResponseDecorator assert response.status == 200: "Request failed with status $response.status. $response.entity.content.text"
Discovered an issue? Report it here

Suggested for you

Appears in these Collections