Hi Everyone,
In our project, there is a scenario where we have sub-tasks if we changed the status of sub-task into "Blocked" all the parent's issue status should be changed to Blocked.
Parent's can be more than 2 levels.
For Ex: Feature(parent)--->Epic(parent)-->Story(parent)--> story has 2 sub-tasks(Assume A &
, if I change the status of A or B to "Blocked" all the parents(All the way to feature) status must be changed to "Blocked".
To achieve this I've written a script which is just updating only parent status not all the layers. If you see above hierarchy if I change the status of Sub-task(A) it only updating the status of Story but not Epic and Feature.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueImpl
import com.atlassian.jira.issue.MutableIssue
import org.apache.log4j.Category
Category log = log
log.setLevel(org.apache.log4j.Level.DEBUG);
if( issue.getIssueType().getName().equals("Sub-task"))
{
log.info(issue.getIssueType().getName())
log.info(issue.getStatus().getStatusCategory().getName())
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
Issue parentIssue = issue.getParentObject()
log.info(parentIssue.getIssueType())
log.info(parentIssue.getIssueType().getName())
log.info(parentIssue.key)
log.info("Updating the parent issue to Blocked")
((IssueImpl) parentIssue).setStatusId("10306");
((IssueImpl) parentIssue).store();
Issue ppIsue = parentIssue.getParentObject()
log.info(ppIsue.getIssueType())
log.info(ppIsue.getIssueType().getName())
log.info(ppIsue.key)
log.info("Updating the Pparent issue to Blocked")
((IssueImpl) ppIsue).setStatusId("10306");
((IssueImpl) ppIsue).store();
}
Any help would be appreciated!
Thanks in advance,
Manikanta