Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,465,047
Community Members
 
Community Events
176
Community Groups

Groovy Script to get Sprint start Date for ACTIVE State sprint

I want to build a custom scripted field that for a given Issue will return the sprint start date BUT only for the active sprint.

In reading the value of the 'Sprint' field I can see the sequence of my sprints is a bit tricky so I cant just use ".first" or ".last" to pull the date i need so i thought I could use the state field to help me select the sprint I need then pull the date from there. I tried
using this modified script but I can't get it to work. Any help would be much appreciated.

 

Script I'm using:


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.link.IssueLinkType
import com.atlassian.jira.issue.link.IssueLinkTypeManager
import java.util.concurrent.TimeUnit
import com.atlassian.jira.issue.CustomFieldManager

def cfManager = ComponentAccessor.getCustomFieldManager()
def issue = issue
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def sprintField = customFieldManager.getCustomFieldObjectByName("Sprint");
def sprints = issue.getCustomFieldValue(sprintField)
def Activesprintstartdate=sprints.state.ACTIVE.startDate?.toDate()

log.warn(Activesprintstartdate)

return Activesprintstartdate


As an example of what I've got for an Issue that appears in more than two sprints ..the bolded underlined date is the one i need. 

2022-05-05 19:04:09,788 WARN [runner.ScriptBindingsManager]: GCP-29181 [com.atlassian.greenhopper.service.sprint.Sprint@40901b8e[id=453,rapidViewId=90,state=CLOSED,name=Sprint 2206,startDate=2022-03-29T21:42:00.000-04:00,endDate=2022-04-12T21:42:00.000-04:00,completeDate=2022-04-12T20:42:35.084-04:00,activatedDate=2022-03-29T21:42:42.195-04:00,sequence=457,goal=,autoStartStop=false], com.atlassian.greenhopper.service.sprint.Sprint@5fd06f96[id=454,rapidViewId=90,state=CLOSED,name=Sprint 2207,startDate=2022-04-12T20:43:00.000-04:00,endDate=2022-04-26T20:43:00.000-04:00,completeDate=2022-04-26T23:44:46.993-04:00,activatedDate=2022-04-12T20:43:07.740-04:00,sequence=463,goal=,autoStartStop=false], com.atlassian.greenhopper.service.sprint.Sprint@65375fe9[id=455,rapidViewId=90,state=ACTIVE,name=Sprint 2208,startDate=2022-04-26T23:45:00.000-04:00,endDate=2022-05-10T23:45:00.000-04:00,completeDate=<null>,activatedDate=2022-04-26T23:45:36.525-04:00,sequence=466,goal=,autoStartStop=false], com.atlassian.greenhopper.service.sprint.Sprint@554fd4d5[id=456,rapidViewId=90,state=CLOSED,name=Sprint 2205,startDate=2022-03-15T23:27:00.000-04:00,endDate=2022-03-29T23:27:00.000-04:00,completeDate=2022-03-29T21:42:05.684-04:00,activatedDate=2022-03-15T23:27:46.895-04:00,sequence=456,goal=,autoStartStop=false]]

1 answer

Hello @Juan Martinez ! Did you ever figure this out? I have the same requirement.

Hi @Jerel Crosland  unfortunately I did not :( 

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events