JIRA Scriptrunner access URL

Hi 

I was wondering if it's possible to get the full URL for the JIRA create issue page from inside Scriptrunner. At the moment I'm able to get the jira.base url from the ApplicationProperties using the ComponentAccessor.

Ideally, I'd like to get the full url, including any arguments contained within the URL. Does another application property or any other component accessor expose this information?

What I'm trying to do is populate some values in a JIRA issue on the create screen using the behaviours part of Scriptrunner. The user will be taken to JIRA with a parameterised URL which fills out some of the fields such as summary, passed in as args.

However, the URL also contains an id field as an argument which I'm hoping Scriptrunner can extract from the URL and then use to poll an API to populate other fields on the create issue page.

Cheers

Paul

1 answer

Since you're working with Behaviours, there's a variable in the binding for the current request. It's an HttpServletRequest object. Inside your Behaviour's Groovy script, you could get the URL as a string using

request.requestURL.toString()

You could then parse that URL string and retrieve its query parameters using normal Java methods. See the answers at https://stackoverflow.com/a/13592324/1524502 for some examples.

You may also want to take a look at the Create Constrained Issue functionality in ScriptRunner.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published 5 hours ago in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

27 views 0 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you