Skip to content

Instantly share code, notes, and snippets.

@jechlin
Created December 12, 2016 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jechlin/2767e05f2ec75acffb6579b025d230b9 to your computer and use it in GitHub Desktop.
Save jechlin/2767e05f2ec75acffb6579b025d230b9 to your computer and use it in GitHub Desktop.
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