I attempted to recreate a script that Tarun Sapra showed in one of his videos to update fix versions of issues linked to a story. I copied it word for word but it does not worked. it's not working at all. I'm hoping that Tarun will be so kind as to shed some light on the possible issue. I added logging info and I see in the logs when it finds an issue that's a story, but when it gets to logs.info "*****change = $change" is says that it's null. Please advise.
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.issue.link.IssueLinkManager;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.event.type.EventDispatchOption;
import org.apache.log4j.Logger
import org.apache.log4j.Level
def logs = Logger.getLogger("com.onresolve.scriptrunner.runner.ScriptRunnerImpl")
logs.setLevel(Level.INFO)
def issue = event.issue
if(issue.issueType.name == "Story") {
logs.info "*****Issue $issue is a story"
def projectKey = issue.projectObject.key;
def change = event?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field == "Fix Version/s"}
logs.info "*****change = $change"
//def change_issue = issue?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field == "Fix Version/s"}
//logs.info "*****change_issue = $change_issue"
def issueLinkManager = ComponentAccessor.issueLinkManager;
def issueManager = ComponentAccessor.issueManager;
if(change) {
issueLinkManager.getOutwardLinks(issue.getId()).each {IssueLink issueLink -> if (issueLink.getIssueLinkType().getName() == "Epic-Story Link") {
def destinationIssue = (MutableIssue)issueLink.getDestinationObject();
if(destinationIssue.projectObject.key.equals(projectKey)) {
destinationIssue.setFixVersions(issue.fixVersions)
logs.info "*****setting up fixVersions $issue.fixVersions"
issueManager.updateIssue(event.getUser(), destinationIssue, EventDispatchOption.ISSUE_UPDATED, false)
}
}
}
}
}