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,369,285
Community Members
 
Community Events
168
Community Groups

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 _Appfire_'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

Atlassian Community Events