/* * 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."*/defissueKey=issue.key/*To store the story points from the issues that are in Done status*/defstoryPoints=[]asList<Double>defresult=get("/rest/api/2/issue/${issueKey}").header('Content-Type','application/json').asObject(Map)if(result.status==200){/*To extract the status name of the linked issues*/defstatusName=result.body.fields.issuelinks['inwardIssue']['fields']['status']['statusCategory']['name']asList<String>/*To extract the list of linked issues linked to the current issue that is being viewed*/deflinkedIssueKey=result.body.fields.issuelinks['inwardIssue']['key']/*To verify that the status of the linked issue(s) is Done*/if(statusName.first().toString()=='Done'){linkedIssueKey.each{deflinkedIssues=get("/rest/api/2/issue/${it}").header('Content-Type','application/json').asObject(Map)if(linkedIssues.status==200){/*To extract the story points from the linked issues and store in the story points list Please ensure that the default value for the Story Points is set to 0. This is to avoid any error if the Story Points is not added to any of the linked issues. */storyPoints<<Double.parseDouble(linkedIssues.body.fields.customfield_10030.toString())}else{"Failed to find issue: Status: ${result.status} ${result.body}"}}}/*To calculate and return the total story points of all the linked issues that are done*/storyPoints.sum()}else{"Failed to find issue: Status: ${result.status} ${result.body}"}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.