Hi gurus,
I am trying to loop through all stories linked to a epic to obtain the story and sprint name that is to be done last to update the EPIC with this sprint name.
I am able to use JQL query to get the stories however I don't seem to be able to see a way to obtain the sprint name from the sprint field returned.
I need now to interrogate this string to obtain the last name in the string. NB - there are often multiple names in the string.
Please help suggest how I do this.
Dave
Hi @Dave Cuff
For your requirement, I suggest using the ScriptRunner console.
Below is a sample working code for your reference:-
import com.adaptavist.hapi.jira.issues.Issues
def epic = Issues.getByKey('MOCK-2')
def links = epic.getOutwardLinks { excludeSystemLinks = false }
links.each {
def issue = it.destinationObject
def sprint = issue.getCustomFieldValue('Sprint')['name'] as List
if (sprint.size() > 0) {
log.warn "=====>>> Isuse Key: ${issue.key}, Last Sprint Name: ${sprint.last()}"
}
}
Please note that the sample code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
Please note that the sample code has been coded using ScriptRunner's HAPI feature. I suggest upgrading your ScriptRunner plugin to the latest release, i.e. 7.13.0 and using the HAPI feature to simplify the coding.
Below is a screenshot of the output returned:-
Below is a screenshot of the sample sprints I am testing with:-
I hope this helps to answer your question. :-)
Thank you and Kind regards,
Ram
Hi @Dave Cuff
If you are not using HAPI, you will need to invoke the ComponentAccessor to access the IssueManager, and via the IssueManager, invoke the issue.
So there are a lot more steps, as shown below:-
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
def issueManager = ComponentAccessor.issueManager
def epic = issueManager.getIssueByCurrentKey('MOCK-2')
def links = epic.getOutwardLinks(epic.id)
links.each {
def issue = it.destinationObject
def sprint = issue.getCustomFieldValue('Sprint')['name'] as List
if (sprint.size() > 0) {
log.warn "=====>>> Isuse Key: ${issue.key}, Last Sprint Name: ${sprint.last()}"
}
}
Please note that the sample code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
I hope this helps to answer your question. :-)
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.