I need a simple script to check if all linked issues which are "is blocked by" are resolved before resolving the issue
import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.component.ComponentAccessor;
def allClosed = true
List<IssueLink> allInIssueLinks = ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.getId());
for (link in allInIssueLinks)
{
if(link.issueLinkType.name == "Blocks")
{
def linked = link.getSourceObject()
if( linked.resolution == null) //You might need to modify this depending on how your project is set up
{
allClosed = false
}
}
}
return allClosed
You might need to change how it determines if an issue is resolved depending on how your project is set up, but this should work.
Did it work? If so, could you mark my response as the answer?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Ben, It is not working.
I added this as validator in the transition however the ransiiton is not stopped if an open blocked by link is available. Its still letting the issue closed
import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.component.ComponentAccessor;
def allClosed = true
List<IssueLink> allInIssueLinks = ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.getId());
for (link in allInIssueLinks)
{
if(link.issueLinkType.name == "Blocks")
{
def linked = link.getSourceObject()
if( linked.resolution == Unresolved) //You might need to modify this depending on how your project is set up
{
allClosed = false
}
}
}
return allClosed
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Delete the validator, then recreate it. Instead of choosing "Simple Scripted Validator", choose "Custom Script Validator".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, been a busy week, just saw this. I misunderstood your original problem- I thought you wanted to only allow the ticket to be closed if all the tickets blocking it were closed, not the other way around. To switch it, just change:
List<IssueLink> allInIssueLinks = ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.getId());
to
List<IssueLink> allOutIssueLinks = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId());
You'll also need to change all uses of allInIssueLinks to use allOutIssueLinks instead. Other than that, you should be good to go.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If anyone finds this and it isn't quite working out for them.
replace
with
because SourceObject is the issue you're in and not the issue on the other side of the link which you want to use for your validator.
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.