Groovy script to get the remote link ID

Vineela Durbha August 13, 2019

I am trying to delete the remote links using groovy script and I encountered below method for the same

removeRemoteIssueLink(Long remoteIssueLinkId, ApplicationUser user)

 

So for this what is the remoteIssuelinkId and how do we fetch it in the script.

Can someone please help me with this

1 answer

1 accepted

0 votes
Answer accepted
Yury Lubanets August 13, 2019

Hi @Vineela Durbha 

You can retrieve all issue's remote issue links using getRemoteIssueLinksForIssue(Issue issue) method and find the link you wanted. After that, you can get the link's ID. Something like this

def remoteLink = remoteIssueLinkManager.getRemoteIssueLinksForIssue(issue).find {it.getTitle() == 'YourLinkTitle'}
def remoteIssueLinkId = remoteLink.getId()
Vineela Durbha August 13, 2019

Hi @Yury Lubanets 

I am trying as below and it is not working


def remoteLink = remoteIssueLinkManager.getRemoteIssueLinksForIssue(issue)
def remoteIssueLinkId = remoteLink.getId()

 

It is throwing error cannot find getId() method . I am not sure on what to pass in Title. So removed that find method 

Yury Lubanets August 13, 2019

remoteIssueLinkManager.getRemoteIssueLinksForIssue(issue) is a List of links. Firstly you should find one you needed link and then you can get the link's ID

The Title is the name of the link you see on an issue. For example, you can get all your issue's link titles

remoteIssueLinkManager.getRemoteIssueLinksForIssue(issue)*.getTitle()

 Or if you want to delete all possible remote links try this

remoteIssueLinkManager.getRemoteIssueLinksForIssue(issue).each { 
remoteIssueLinkManager.removeRemoteIssueLink(it.getId(), user)
}
Vineela Durbha August 13, 2019

@Yury Lubanets 

 

It worked. Thank you so much :)

Suggest an answer

Log in or Sign up to answer