I need to automatically update the Sprint end date .
The End date of the SPRINT should be the last STORY complete date in the sprint.
1. Any default option in jira ?
2. Any available option with script runner.
NEW CASE :
1,Epic end date should dynamically get updated based on story tagged to last created Sprint
Hi @siva ,
See this script :
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.status.category.StatusCategory
import java.sql.Timestamp;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
// the name of the issue link
final String issueLinkName = "Epic-Story Link"
def issueLinkManager = ComponentAccessor.issueLinkManager
def epicIssue = issueLinkManager.getInwardLinks(issue.id).find { it.issueLinkType.name == issueLinkName }?.sourceObject
//If the story is not attached to an Epic, do nothing
if (!epicIssue) {
return
}
// Find all the linked - with the "Epic-Story Link" link - issues that their status is not completed
def linkedIssues = issueLinkManager
.getOutwardLinks(epicIssue.id)
.findAll { it.issueLinkType.name == issueLinkName }
*.destinationObject?.findAll { StatusCategory.COMPLETE != it.status.statusCategory.key}
// If there are still open linked issues (except the one in transition) - then do nothing
if (linkedIssues.size > 0){
return
}
int dateFieldId = 11200
def dateField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(dateFieldId)
def dateFieldValue = epicIssue.getCustomFieldValue(dateField)
int sprintFieldId = 10100
def sprintField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(sprintFieldId)
def sprintFieldValue = issue.getCustomFieldValue(sprintField)?.endDate?.first()?.toDate()
if (sprintFieldValue){
dateField.updateValue(null, epicIssue, new ModifiedValue(dateFieldValue, new Timestamp(sprintFieldValue.getTime())), new DefaultIssueChangeHolder())
} else {
dateField.updateValue(null, epicIssue, new ModifiedValue(dateFieldValue, new Timestamp(new Date().getTime())), new DefaultIssueChangeHolder())
}
attach it to the last transition of the story workflow. It will update the end date value of the epic if all linked stories are in a green status. The end date value will either be :
(Check your field ids beforehand)
Hope that is what you are asking for.
Antoine
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.
@siva You are very welcome !
Please mark this answer as accepted so it can help others in the future.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.