Hello all together,
I'm in Jira Datacenter 9.4.8 running Automation for Jira version 9.1.1 and ScriptRunner version 8.29.0.
Within a manually triggered automation rule I need a groovy script to add the components of some linked issues to the trigger issue.
I've tried many ways, but there seems to be no way to do the add.
I've found some ways where I didn't get any error, but the components were not added.
This is one of my variants for you to understand what I'm trying to do:
import com.atlassian.jira.component.ComponentAccessor
def linkedIssues = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())?.findAll
{it.issueLinkType.inward == "Ticket enthalten in Softwarefreigabe / Issue included in Software Approval"}
def linkedIssue = null;
def comp = null;
for (int i = 0; i < linkedIssues.size(); i++) {
linkedIssue = linkedIssues[i].destinationObject
comp = linkedIssue.getComponents()
issue.components.addAll(comp)
}
I think you have a problem with how you're testing for the issue link type.
getOutwardLinks returns a list of IssueLink objects, and you're trying to fid those issues of a particular link type by looking at the .inward attribute, which I don't think exists.
The link type is available via the getIssueLinkType method, which returns an IssueLinkType.
I also prefer using .each to iterate lists, so you'll end up with something more like this:
import com.atlassian.jira.component.ComponentAccessor
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def linkedIssues = issueLinkManager.getOutwardLinks(issue.getId())?.findAll {
it.getIssueLinkType().getInward() == "Ticket enthalten in Softwarefreigabe / Issue included in Software Approval"
}
if (linkedIssues) {
linkedIssues.each { link ->
def linkedIssue = link.destinationObject
def components = linkedIssue.getComponents()
if (components) {
issue.components.addAll(components)
}
}
}
This is completely untested, no guarantees of anything.
Unfortunately your script doesn't bring any error (like mine) but does not have any effect on the issue (like mine).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.