You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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
Thank you for this.
We don't have hapi yet. "I am not happy"
Any suggestions if you don't have HAPI.
Dave
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.