/** This example script listener script shows how to send a notification when the priority changes to highest.* Note: This should be configured to run as the ScriptRunner Add-On User and on the Issue Updated Event* Note: The condition to add to the Script Condition box is issue.priority.name == 'Highest'* "All right, title and interest in this code snippet shall remain the exclusive intellectual property of Adaptavist Group Ltd and its affiliates. Customers with a valid ScriptRunner* license shall be granted a non-exclusive, non-transferable, freely revocable right to use this code snippet only within their own instance of Atlassian products. This licensing notice cannot be removed or* amended and must be included in any circumstances where the code snippet is shared by You or a third party." */// This script should be configured to run as the ScriptRunner Add-On User and on the Issue Updated Event// In the conditions box the condition below must be added:// issue.priority.name == 'Highest'// Construct the message bodydefmessageBody="<p>The <b>${issue.key}</b> ticket has been set to the <b>Highest</b> priority.</p><p> Please action this issue immedietly</p>"// Send the email notificationdefsendNotification=post("/rest/api/2/issue/${issue.key}/notify").header("Content-Type","application/json").body([subject:"The priority was set to Highest on the ${issue.key} issue",htmlBody:messageBody,to:[assignee:issue.fields.assignee!=null,watchers:true,]]).asString()// Validate the notification sent correctlyassertsendNotification.status>=200&&sendNotification.status<300// Log out the notification sent correctlylogger.info("Notification sent succesfully when the ${issue.key} was updated and the priority set to Highest");
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.