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
So posing this question here is a stretch I know, but I'm hoping to use scriptrunner to create a custom field that calls the count of previous sprints that an issue has been in, in order to calculate how many times it has rolled over. I used this groovy script, and it retrieved the current sprint ONLY:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def sprintCf = customFieldManager.getCustomFieldObjectByName("Sprint")
Issue issue = issue
issue.getCustomFieldValue(sprintCf)
But I want all of the old sprints from change history, not just the current one.
I know I can invoke ChangeHistoryItem function but don't have the groovy skills to get it to work.
I found the api documentation but it doesn't tell me field names so I'm stuck.
Any groovy wizards around?
You can extract all the changes for a specific field like this:
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.greenhopper.service.sprint.SprintManager
@JiraAgileBean SprintManager sprintManager
def chm = ComponentAccessor.changeHistoryManager
def sprintChangeItems = chm.getChangeItemsForField(issue, 'Sprint')
if(!sprintChangeItems) return null
(sprintChangeItems.from + sprintChangeItems.to).unique().findAll().collect{sprintManager.getSprint(it as Long) }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.