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

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

arama mihai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 6, 2018

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

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 6, 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.

arama mihai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 6, 2018

Thank you very much, that works!

0 votes
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 6, 2018

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 6, 2018

Just to add to @Alexey Matveev'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)

arama mihai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 6, 2018

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 6, 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 

arama mihai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 6, 2018

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!

TAGS
AUG Leaders

Atlassian Community Events