Add or Update the Issue Link for an Issue in Jira


Linking issues means you can create an association between two existing issues. With this script, you can bulk link a set of issues.


I want to bulk link issues to keep track of my related work for one of my projects. I can do this quickly and efficiently with this script.


Jira Jira (7.7 - 8.6)

import com.atlassian.jira.component.ComponentAccessor import // the issue key to create the link from final String sourceIssueKey = "JRA-1" // the issue key to create the link to final String destinationIssueKey = "SSPA-1" // the name of the issue link final String issueLinkName = "Blocks" // the sequence of the link final Long sequence = 1L def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser def issueLinkTypeManager = ComponentAccessor.getComponent(IssueLinkTypeManager) def issueManager = ComponentAccessor.issueManager def sourceIssue = issueManager.getIssueByCurrentKey(sourceIssueKey) def destinationIssue = issueManager.getIssueByCurrentKey(destinationIssueKey) assert sourceIssue && destinationIssue: "One ore more issues do not exist" def availableIssueLinkTypes = issueLinkTypeManager.issueLinkTypes def linkType = availableIssueLinkTypes.findByName(issueLinkName) assert linkType : "Could not find link type with name $issueLinkName. Available issue link types are ${availableIssueLinkTypes*.name.join(", ")}" ComponentAccessor.issueLinkManager.createIssueLink(,,, sequence, loggedInUser)
Discovered an issue? Report it here

Suggested for you