Dear community,
I've tried to find a solution, but could only find something like "Linked status validation" or a solution with some plugins I don't use. We only use script runner. Someone has a idea for a groovy script to get a resolution here?
Befor a certain transition can be done, there must be at least one issue (relationship does not matter) linked to the issue. I'd like to get this into a code but always struggle with the script runner APIs and I am not really used to groovy..
The condition is "simply": Linked issues != null.
Thanks in advance
Vedat
We used the following script to assure that there is at least one link of a particular type and that the linked issue is complete.
Our script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
def issueLinks = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())
def numClosedPceIssues = 0
for(IssueLink i in issueLinks)
{
//want only PCE links
if(i.getIssueLinkType().getName() == "PCE")
{
def linkedObject = i.getDestinationObject()
//want only PCE issues with resolution of Complete
if(linkedObject.getIssueType().getName() == "PCE" && linkedObject.getResolution()?.getName() == "Complete")
{
numClosedPceIssues++
}
}
}
return numClosedPceIssues > 0
Sounds more complex than you need, so you can likely pare it down to:
import com.atlassian.jira.component.ComponentAccessor
def issueLinks = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())
return issueLinks.size() > 0
You may also wish to check inward and outward links if direction doesn't matter, e.g.
import com.atlassian.jira.component.ComponentAccessor
def outwardLinks = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())
def inwardLinks = ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.getId())
return outwardLinks.size() + inwardLinks.size() > 0
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.