Hi All,
My JIRA instance have issues linked to other issues with a specific link type, e.g (relates to) and specific issue type, e.g (bug) I'm trying to sum all the work logged in all bug issues with relates to link . Example. Ticket ABC-1 is linked to ABC-2(release), ABC-3(bug), ABC-4 (bug), ABC-5(bug) and BCD-1 (new) (in another project) i'm trying to sum total work log in all these tickets and store it in a scripted field eventually for this project. I found out that using groovy script is the best way to do it. I have done some research and I have written this code from script console to try out but i'm stuck. ABC-2 has work logged as null, but the rest of the issues has work logged. I cannot seem to continue checking the rest of the issues apart from the first one from the script and I'm stuck Here is the script. Please help
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueManager
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def issueManager = ComponentAccessor.getIssueManager()
MutableIssue issue = issueManager.getIssueObject("ABC-1")
def totalTimeSpent = 0
issueLinkManager.getOutwardLinks(issue.id).each {issueLink ->
def linkedIssue = issueLink.destinationObject
if(issueLink.issueLinkType.name == "Relates" || linkedIssue.getIssueType() == "Bug"){
def linkedIssueTimeSpent = linkedIssue.timeSpent
if(linkedIssueTimeSpent) {
totalTimeSpent += linkedIssueTimeSpent
}
}
}
if(totalTimeSpent > 0) {
totalTimeSpent = totalTimeSpent / 60.0d / 60.0d / 8.0d
return (double)totalTimeSpent
}
else{
null
}