Unable to create an remote link using RemoteIssuelinkService API

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 13, 2018

Hello All,

I am trying to create an Remote Link for an issue in my current instance with an issue in the remote instance. The code part is clear to me. Here's the snippet. I am trying the script in the script console for the time being.

def remoteIssueLinkService = ComponentAccessor.getComponent(RemoteIssueLinkService);
def builder = new RemoteIssueLinkBuilder();

builder.issueId(issue.id);
def appLinkId = finalLink.getId(); // application link id
def issueId = "51295"
builder.globalId("appLinkId="+appLinkId.get()+"&issueId="+issueId)
builder.url("https://jira.instance.com/browse/CHANG-3315")
builder.title("Issue in remote JIRA test")
builder.relationship("relates to")
builder.applicationName("Remote JIRA")
builder.applicationType("com.atlassian.jira")
builder.resolved(false)



def remoteIssueLink = builder.build();

log.info(remoteIssueLink.getGlobalId())

def validationResult = remoteIssueLinkService.validateCreate(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(),remoteIssueLink);

log.info(validationResult.isValid())

if(validationResult.isValid()) {
def result = remoteIssueLinkService.create(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), validationResult)
log.info "result is" + result;
} else {
log.error validationResult.errorCollection.errorMessages

 I see the error in the logs

Remote link aggregation cache clearing webhook failed - exception.

There is an open ticket as well - https://jira.atlassian.com/browse/JRASERVER-46608

When I visit the issue view screen of the current instance then I see the remote issue link being created but with a message "Failed to load" and a rotation icon Gif next to it. But the title and the URL which I set in the remoteIssueBuilder points to the correct remote issue in the  partially created failed link. 

Thus, I wanted to know is it not working because of the above open issue or am I missing some data in the remote issue link builder? or can it be something else. As I have done something similar before (JIRA 6.x) and it worked like a charm but not anymore. I am using JIRA Server 7.4.3

 

Thanks,

tarun

2 answers

0 votes
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 23, 2019

Hi Tarun,

Could you clarify if the issue link is being created here or not?   From what I have read I believe that it is, however the Jira logs still record this exception.   The bug ticket you linked to appears to be related to this problem, however the original report of this problem in that bug ticket did indicate that the issue link does appear to work.  Just want to better understand the scope of this problem.

I can't say for sure if your specific code has any differentiating affect on this.  It does seem that other users have encountered this problem between Jira and other application linked programs, like Confluence, Bamboo, etc. When you create issue links like this to another Jira, or from another application to Jira, you're utilizing an existing application link with that Jira site.  

I would be interested to learn more about that specific application link to better understand the problem.  For example, the URL in use, the authentication method employed by that application link, and the versions of both applications in question.   Each application could be utilizing different versions of the applink libraries, which might also play a role in why this error might be getting generated.  

Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 23, 2019

Another thing to try: Without utilizing your code above, try to create an issue link in the Jira web UI between these two issues on different Jira sites.    I am curious to see if this process behaves any differently in regards to the actions/results/log exceptions that appear in your environment.

Adolfo Casari
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 23, 2019

@Andy HeinzerIn my case this is the main part of the code. It´s between Jira Software 7.9 and Jira Service Desk 3.12.2

linkBuilder.issueId(issue.id)
linkBuilder.url("http://<base url>/" + Issue_Remoto_Value)
linkBuilder.title(Issue_Remoto_Value)
linkBuilder.relationship("ticket asociado")
linkBuilder.applicationType("APPLICATION_TYPE_JIRA")
linkBuilder.applicationName("Jira Service Desk")
linkBuilder.statusName(issue.getStatus().getName())
linkBuilder.statusIconUrl("http://<base url>/" + issue.getIssueType().iconUrl)
linkBuilder.globalId("appId="+appLinkId.get()+"&issueId="+issue.id)

 

In the logs I see:

Remote link aggregation cache clearing webhook failed - exception.

 As for the link view in Jira, it´s OK, except that I can´t see the status of the remote issue. When I use Link from Jira, it does.

I am using Applications Link with OAuth (with impersonation) for both local and remote.

 

I would like to get the same performance that if I were using Jira´s Link for linking the issues.

 

Thanks.

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 24, 2019

Hello @Andy Heinzer

Thanks for your response. Since I was trying this in last year feb thus I might not remember all details of the process but I clearly remember the following things

  • The remote link was not created, in the end I added the URL to the issue in the comments using commentManager.
  • The two Jira applications are connected via - OAuth (impersonation)
  • The host instance was at JIra 7.7 and the target (remote instance) was at 7.3
  • From the UI it's easy to link the issues of both instance with each other.
0 votes
Adolfo Casari
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 22, 2019

@Tarun Sapra, Did you find a solution? I am runnning into the same error. I am with JIRA 7.9.

Kirils Ruskulis July 19, 2019

@Adolfo Casari  following globalId format fixed failed to load issue for me:

def globalId = 'appId=RemoteJirasAppLinkID&issueId=RemoteIssueId'    
Adolfo Casari
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 22, 2019

@Kirils RuskulisHi, what are the value you used for:

RemoteJirasAppLinkID and RemoteIssueId

 

Kirils Ruskulis September 10, 2019

@Adolfo Casari Hi,

for RemoteJirasAppLinkID i used Application Link ID which you can find in Application Link configuration (like you can find customfield ID) RemoteIssueID was taken from sessionDetails.issues.id

def quer='issuekey=someJQL'
def request = applicationLinkRequestFactory.createRequest(GET, "/rest/api/2/search?jql=${quer}")

def handler = new ApplicationLinkResponseHandler() {
@Override
def credentialsRequired(Response response) throws ResponseException {
return null
}

@Override
def handle(Response response) throws ResponseException {
assert response.statusCode == 200
new JsonSlurper().parseText(response.getResponseBodyAsString())
}
}

def sessionDetails = request.execute(handler)

Suggest an answer

Log in or Sign up to answer