Heads up! On March 5, starting at 4:30 PM Central Time, our community will be undergoing scheduled maintenance for a few hours. During this time, you will find the site temporarily inaccessible. Thanks for your patience. Read more.
×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')
}
Could you please clarify how you are trying to trigger the update? Are you doing this via Post-Function or ScriptRunner Console?
I am looking forward to your feedback and clarification.
Thank you and Kind regards,
Ram
Hi @Ram Kumar Aravindakshan _Adaptavist_
the plan is to handle this in a listener, whenever the date of a certain issue type (which is assigned to the sprint only once) is changing. To keep this issue in sync with the sprint dates.
But for now, I am trying to achieve this by using the Script Console for testing purposes. So the above script is to be running from the Script Console.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.