Snippets

Adaptavist Notify Users of Inactive issues that have not been updated in the past 5 days

Created by Kristian Walker last modified
/*
* This example escalation service script should be conifgured to run on a schedule such as at 9am every day and should use the JQL query below for the JQL query
* Project = KWTEST AND issuetype = Story AND status in ("In Progress") AND assignee is not empty And updated >-5d
* "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." 
*/

// Construct a comment to the inactive issue
def inActiveIssueComment = """ *****************************
This issue which is assigned to ${issue.fields.assignee.displayName} has not been updated for the past 5 days. \n
Can you please add an update on this issue. \n
***************************** """;

// Construct a slack message saying which issue is inactive
def inActiveIssueMessage = """ *****************************
The issue with the key of ${issue.key} which is assigned to ${issue.fields.assignee.displayName} has not been updated for the past 5 days.
***************************** """;

// Add a comment to each issue mentioning that it needs updating
post("/rest/api/2/issue/${issue.key}/comment")
    .header('Content-Type', 'application/json')
    .body([
            body: inActiveIssueComment
    ])
    .asObject(Map)

// Post a message to slack for each issue mentioning it needs updating 

// Construct the meta data needed for the update message
    Map msg_meta = [channel: 'scriptrunner-jira-cloud-post-to-slack-demo', username: 'Inactive Issue Notifier', icon_emoji: ':clipboard:']
    
    // Construct the message string to post to slack
    def slackMessage = inActiveIssueMessage

// Construct the message body
    Map msg_dets = [text: slackMessage]

// Post the message to slack
    def supportRotaUpdateMessage = post('https://slack.com/api/chat.postMessage')
            .header('Content-Type', 'application/json')
            .header('Authorization', "Bearer ${SLACK_SRCLOUD_TOKEN}")
            .body(msg_meta + msg_dets)
            .asObject(Map)

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.