Hi all,
I am trying to modify the sprint end date for some conditions. For testing purposes, I want to set it to the current date, but it does not appear to be changed at all. Manually changing is possible, so there is no question of permissions.
This is my script for changing it:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.fields.CustomField
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.atlassian.greenhopper.service.sprint.Sprint
import com.atlassian.greenhopper.service.sprint.SprintManager
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
@WithPlugin(['com.pyxis.greenhopper.jira',])
IssueManager issueManager = ComponentAccessor.getIssueManager()
def issue = issueManager.getIssueObject("issueKey")
@JiraAgileBean
SprintManager sprintManager
CustomFieldManager cfManager = ComponentAccessor.getCustomFieldManager()
def cf = cfManager.getCustomFieldObjects(issue).find { CustomField it -> it.name == 'Sprint'}
List<Sprint> sprints = issue.getCustomFieldValue(cf) as List<Sprint>
def outcome = sprintManager.updateSprint(Sprint.builder(sprints.last()).endDate(new Date().clearTime().time).build())
log.warn(outcome)
if(outcome.isInvalid()) {
log.warn('Outcome invalid')
}
It is absolutely strange as the first log is showing the Sprint with the updated end date. However, it appears that the update of the sprint is somehow not persisted in the system.
Can you let me know, what I may do wrong here?
Thanks!
Stefan