In this example, we will see in a script field all the tickets linked that uses a link type “Trigger” relation


import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.index.IndexException
import com.atlassian.jira.ManagerFactory
import com.atlassian.jira.user.ApplicationUser
import org.apache.log4j.Category
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.link.IssueLink;

def issueLinkManager = ComponentAccessor.getIssueLinkManager()

def links = "";
List allOutIssueLink = issueLinkManager.getInwardLinks(issue.id);
for (Iterator outIterator = allOutIssueLink.iterator(); outIterator.hasNext();) {
IssueLink issueLink = (IssueLink) outIterator.next();
def linkedIssue = issueLink.getSourceObject();
if ( issueLink.issueLinkType.name.contains('Trigger')) {
links = links + ", " + linkedIssue.getKey();
}
}
allOutIssueLink = issueLinkManager.getOutwardLinks(issue.id);
for (Iterator outIterator = allOutIssueLink.iterator(); outIterator.hasNext();) {
IssueLink issueLink = (IssueLink) outIterator.next();
def linkedIssue = issueLink.getDestinationObject();
if ( issueLink.issueLinkType.name.contains('Trigger')) {
links = links + "," + linkedIssue.getKey();
}
}

//return links
if (links.size()>1) {
return links.substring(1,links.size());
} else {
return "";
}

That’s all!

By MrAddon

Advertisements
Posted by:.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s