Created
December 12, 2016 10:37
-
-
Save jechlin/2767e05f2ec75acffb6579b025d230b9 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 | |
import com.atlassian.jira.bc.issue.IssueService | |
import com.atlassian.jira.component.ComponentAccessor | |
import com.atlassian.jira.event.issue.IssueEvent | |
import com.atlassian.jira.event.type.EventDispatchOption | |
IssueEvent event = event | |
def issue = event.issue | |
if (! event.getChangeLog()?.getRelated("ChildChangeItem")?.any { it.get('field') == "summary"}) { | |
return | |
} | |
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() | |
def issueService = ComponentAccessor.issueService | |
issue.subTaskObjects.each { subtask -> | |
def issueInputParameters = issueService.newIssueInputParameters() | |
issueInputParameters.setSummary(issue.summary) | |
IssueService.UpdateValidationResult updateValidationResult = issueService.validateUpdate(user, subtask.id, issueInputParameters) | |
if (updateValidationResult.isValid()) { | |
IssueService.IssueResult updateResult = issueService.update(user, updateValidationResult, EventDispatchOption.ISSUE_UPDATED, false) | |
if (updateResult.isValid()) { | |
log.debug 'Issue updated: ' | |
} else { | |
log.error "Error updating subtask: ${subtask.key} - ${updateResult.getErrorCollection()}" | |
} | |
} else { | |
log.error 'Error validating update' + updateValidationResult.getErrorCollection() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment