Page tree
Skip to end of metadata
Go to start of metadata
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkTypeManager

final String sourceIssueKey = "-1"

final String destinationIssueKey = "SSPA-1"

final String issueLinkName = "Blocks"


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(sourceIssue.id, destinationIssue.id, linkType.id, sequence, loggedInUser)

  • No labels