Hi,
jira is running on Server.
Script Runner for Jira is used.
Issue is linked, untill the linked issue is close ..the issue from which it is linked must not be able to move to next status.
Code is required, Please help me.
Regards,
Abhishree Nagesh
There might by typos, but I think this does the trick.
Script below checks all linked issues (careful to specify link type and inward/outward) and checks if any of the linked issue has a status not equal to Closed , it returns false
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.MutableIssue
Issue sourceIssue = issue
def List<IssueLink> allIssueLinks
List<Issue> allLinkedIssues = new ArrayList<Issue>()
def String initialLinkName = 'linkTypeName'
def String linkType = 'yourLinkType'
def boolean passesCondition = true //default is true, only change to false if any of linked issues is not closed
def linkedIssueStatus = 'Closed'
//depending on link type, either use inward or outward links
switch(linkType){
case 'Inward':
allIssueLinks = ComponentAccessor.getIssueLinkManager().getInwardLinks(sourceIssue.getId())
if(allIssueLinks){
for(Iterator<IssueLink> iterator = allIssueLinks.iterator(); iterator.hasNext();) {
IssueLink issueLink = (IssueLink) iterator.next()
String linkName = issueLink.getIssueLinkType().getName()
if(linkName.equals(initialLinkName)){
allLinkedIssues.add(issueLink.getSourceObject())
}
}
}
break
case 'Outward':
allIssueLinks = ComponentAccessor.getIssueLinkManager().getOutwardLinks(sourceIssue.getId())
if(allIssueLinks){
for(Iterator<IssueLink> iterator = allIssueLinks.iterator(); iterator.hasNext();) {
IssueLink issueLink = (IssueLink) iterator.next()
String linkName = issueLink.getIssueLinkType().getName()
if(linkName.equals(initialLinkName)){
allLinkedIssues.add(issueLink.getDestinationObject())
}
}
}
break
default :
break
}
if(allLinkedIssues){
//check linked issues
for(Issue linkedIssue : allLinkedIssues){
if(linkedIssue.getStatus().getName() != linkedIssueStatus ){
passesCondition = false
}
}
}
return passesCondition
//x
Thank you for your quick reply ..but i have no idea what has to be edited in the
def String initialLinkName = 'linkTypeName'
def String linkType = 'yourLinkType'
so please help me .
Regards,
Abhishree Nagesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
linkTypeName - this is the link type name (example : Relates, Request, Duplicate) etc
linkType - defines if the link is initiated from the actual issue (outward) or if some other issue is linking to the current issue (inward). this you can just try with your linked issue :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.