Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to change a Sprint's end date via groovy or api? Edited

Hello,

Is it possible to change a sprint's end date using scriptrunner?

Example: 

given a sprint name, using the script console, to change the end date for that sprint from the 9th of july to the 30th of July. 

 

What would also be good is if I could clear a sprint's start and end date via the console.

I'm mentioning that the sprint is not started, but it has an end date because of a synchronization done by BigPicture Gantt module which adds end dates to sprints.

Thank you!

2 answers

1 accepted

1 vote
Answer accepted
Tarun Sapra Community Leader Aug 06, 2018

You are passing "java.sqlTimestamp" instead of expected types in the method

Possible solutions: endDate(java.lang.Long), endDate(org.joda.time.DateTime),

Try something like this , there System.currentTimeMillis returns current time in long.

def newSprint = sprint.builder(sprint).endDate(System.currentTimeMillis()).build()

Please see this thread for more details.

Thank you very much, that works!

0 votes

Hello,

Kindly read the following thread:

https://community.atlassian.com/t5/Answers-Developer-Questions/Change-sprint-value-by-groovy-script/qaq-p/522895

There is an idea on how to work with sprints in groovy

Tarun Sapra Community Leader Aug 06, 2018

Just to add to @Alexey Matveev _cPrime_'s answer, you can use the sprintBuilder and use the existing sprint object but set the new endDate which you want.

Set new endDate using the builder

https://docs.atlassian.com/jira-software/6.0.7/com/atlassian/greenhopper/service/sprint/Sprint.SprintBuilder.html#endDate(java.lang.Long)

Use existing sprint object in the builder -

https://docs.atlassian.com/jira-software/6.0.7/com/atlassian/greenhopper/service/sprint/Sprint.html#builder(com.atlassian.greenhopper.service.sprint.Sprint)

Hello,

Thank you for your replies.

Currently I have something that returns the sprint name and dates.

import com.atlassian.greenhopper.service.sprint.Sprint
import com.atlassian.greenhopper.service.sprint.SprintManager
import com.onresolve.scriptrunner.runner.customisers.PluginModuleCompilationCustomiser
import com.onresolve.scriptrunner.runner.customisers.WithPlugin

def sprintManager = PluginModuleCompilationCustomiser.getGreenHopperBean(SprintManager)

def sprintServiceOutcome = sprintManager.getAllSprints()

if (sprintServiceOutcome.valid) {
def sprint = sprintServiceOutcome.getValue().find {it.name == "my_sprint_name"} as Sprint

return sprint 
}

I do not know how to use sprintBuilder to set a certain date. Could you please help with that?

Thank you.

Tarun Sapra Community Leader Aug 06, 2018
def sprint = sprintServiceOutcome.getValue().find {it.name == "my_sprint_name"} as Sprint 
def newSprint = sprint.builder(sprint).endDate(<Your Date in long>).build()
def outcome = sprintManager.updateSprint(newSprint)

This should do it, above code doesn't include logging thus please add loggin as per the example link shared by Alexey 

Hi Tarun,

 

Thank you for your reply.

 

I tried the following:

def sprint = sprintServiceOutcome.getValue().find {it.name == "name"} as Sprint
def todaysDateTime = new Timestamp((new Date()).time)
def newSprint = sprint.builder(sprint).endDate(todaysDateTime).build()
def outcome = sprintManager.updateSprint(newSprint)

 

No signature of method: com.atlassian.greenhopper.service.sprint.Sprint$SprintBuilder.endDate() is applicable for argument types: (java.sql.Timestamp) values: [2018-08-06 13:57:01.931] Possible solutions: endDate(java.lang.Long), endDate(org.joda.time.DateTime), name(java.lang.String), state(com.atlassian.greenhopper.service.sprint.Sprint$State)

I also tried with 

def newSprint = sprint.builder(sprint).endDate(1533556077000).build()

but it still gives the same error. 

Do you also know how the correct format looks like? 

Thank you very much!

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

225 views 2 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you