Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ScriptRunner to return an issue's URL in a post function?

Quin Kan April 26, 2019

Hello

I am new to ScriptRunner and JIRA API.

I am trying to add post function in a transition in the workflow that it returns the destination link of the issue.

It appears the following contains the link
com.atlassian.jira.issue.link.getDestinationObject

Is that correct?
If so, what method in getDestinationObject can I call to return the link?

In terms of syntax in ScriptRunner, what should I use?

Thanks

2 answers

1 accepted

1 vote
Answer accepted
PD Sheehan
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.
April 26, 2019

The com.atlassian.jira.issue.link.IssueLink is what the getDestinationObject method is  from.

This class is what describes objects that links an issue to other issues. That has nothing to do with the URL.

I am not aware of a direct way to get the URL from an issue object.

But as far as I know, all Issue URLs are formed by ${jiraBaseURL}/browse/${issue.key}.

So, in a post function script (issue object is already defined), you can do something like this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.properties.APKeys

def baseUrl = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL)
def issueUrl = "$baseUrl/browse/$issue.key"
Quin Kan April 26, 2019

Thanks for your prompt reply, information and code! 

I was able to make use of it and generate the URL link to the issue.

Best regards!

PD Sheehan
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.
April 26, 2019

My pleasure.

Be sure to click the accept answer so that others can find it and it will appear as "solved".

0 votes
Alex Christensen
Community Champion
April 26, 2019

The package/class/method of com.atlassian.jira.issue.link.getDestinationObject is not a URL - this is associated with linking issues in Jira together as mentioned here. The getDestinationObject() method returns an Issue object.

Is this URL supposed to be in a comment? Is it supposed to be saved in a custom field? What is your intention with this URL? That would determine how you need to create your script post-function, in my opinion.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events