Created
October 19, 2016 08:36
-
-
Save jechlin/573aa77aadacfd5ed05f0adc5744727a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package examples.answers | |
| import com.atlassian.jira.component.ComponentAccessor | |
| import com.atlassian.jira.issue.Issue | |
| import com.atlassian.jira.issue.MutableIssue | |
| import com.onresolve.scriptrunner.runner.customisers.ContextBaseScript | |
| import groovy.transform.BaseScript | |
| @BaseScript ContextBaseScript context | |
| issue = getIssueOrDefault("JRA-3") as MutableIssue | |
| def issueLinkManager = ComponentAccessor.getIssueLinkManager() | |
| def issueService = ComponentAccessor.getIssueService() | |
| def currentUser = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser() | |
| def updateInitiative = {Issue initiative -> | |
| if (initiative.issueType.name == "Initiative") { | |
| log.debug("found an initiaive - key is ${initiative.key}") | |
| def parameters = issueService.newIssueInputParameters() | |
| def result = issueService.validateTransition(currentUser, initiative.id, 4, parameters) | |
| issueService.transition(currentUser, result) | |
| } | |
| } | |
| issueLinkManager.getOutwardLinks(issue.id).each { link -> | |
| def initiative = link.destinationObject | |
| updateInitiative(initiative) | |
| } | |
| issueLinkManager.getInwardLinks(issue.id).each { link -> | |
| def initiative = link.sourceObject | |
| updateInitiative(initiative) | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Auto-Close Epics if all the stories are closed.