Snippets

Adaptavist Get sum of story points from the Epic from specific issue types

Created by Ram Kumar Aravindakshan last modified Kristian Walker
/*
 * 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."
*/

def issueKey = 'MOCK-1' //Change the Epic Key according to your environment

def jql = "rest/api/2/search?jql='Epic Link'=${issueKey}"

def filteredJql = jql.replace(" ","%20").replace('"',"%22")

def body = get(filteredJql).asObject(Map).body
       
def issuesInEpic = body['issues']['key'] 

def storyPoints = [] as List<Double>


issuesInEpic.findAll {
    def childIssue = get("/rest/api/2/issue/${it}").header('Content-Type', 'application/json').asObject(Map)
    def issueType = childIssue.body.fields['issuetype']['name']
    
    if (issueType in ['Story', 'Task']) {

        //Change the custom field id according to your Cloud instance
        storyPoints << Double.parseDouble(childIssue.body.fields['customfield_10018'] as String)  
    }
}

storyPoints.sum()

Comments (0)

HTTPS SSH

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