The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Can you update Scriptrunner Script Variables automatically?

Tyler Bell
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 11, 2019

I have a script variable that stores a refresh token for an Oauth2.0 authentication which I use to request access tokens from a script listener. However I would like to automate the process of resetting this script variable when the token expires. Is this possible, or else, is there another way I can store this where it can be updated from a script? 

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Answer accepted
Kristian Walker _Adaptavist_
Community Champion
April 12, 2019

Hi Tyler,

I can confirm that it is not possible to programatically clear or set the values of Script Variables inside of Jira Cloud using ScriptRunner for Jira Cloud as Atlassian do not provide the API's to achieve this functionality.

Script Variables are designed to store items which can be shared acrross scripts and can only be updated on the Script Variables page as described here

I can also confirm that there is no other way to store a global variable inside of Jira cloud as Atlassian do not provide any access to the file system on Jira Cloud

You can see more detailed information on the API's between Jira Cloud and Jira Server in the documentation page located here

If this response has answered your question can you please mark it as accepted so that other users can see it is correct when searching for similar answers.

Regards,
Kristians

1 vote
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 Champions.
April 11, 2019

I don't know if that would be any sort of best practice ... or if that's even possible with cloud, but on server, my first goto would be to store the token in a custom application property.

//store a custom property
ComponentAccessor.applicationProperties.setString("com.acme.myoauthtoken", "put your token here")


//retreive a custom property
def mytoken = ComponentAccessor.applicationProperties.getString("com.acme.myoauthtoken")