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.ComponentAccessorimport com.atlassian.jira.issue.Issueimport com.atlassian.jira.issue.link.IssueLinkimport com.atlassian.jira.issue.MutableIssue Issue sourceIssue = issuedef List<IssueLink> allIssueLinksList<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 closeddef linkedIssueStatus = 'Closed'//depending on link type, either use inward or outward linksswitch(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
@Gezim Shehu [Communardo]
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 .
Hi @Abhishree Nagesh,
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
It looks like you're new here. Sign in or register to get started.