Can you update Scriptrunner Script Variables automatically?

Tyler Bell 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

1 vote
Answer accepted
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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")

Suggest an answer

Log in or Sign up to answer