How to set up Script Variables in Script Runner

Jean Rodriguez August 1, 2017

I read the following documentation on Script Variables in Script Runner (http://scriptrunner-docs.connect.adaptavist.com/jiracloud/script-variables.html) and how to use it in your script, but it does not describe how to set up a variable.

For example, in the documentation it say's that the variable

MY_FIRST_SHARED_VAR

has the value

testValue

but how do you set that variable and where? Do you set it up in JIRA or the server that is running JIRA?

3 answers

0 votes
Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 21, 2020

Hi

Yes - it seems I gave you a link that only works in cloud

For one of our Data Centre projects, in order to set global properties, that differ for dev, staging and prod, we put the values into jira-config.properties on the the servers.

sysAcc = jirauser

Then

def propertyManager = ComponentAccessor.getApplicationProperties()

def myUsername = propertyManager.getDefaultBackedString('sysAcc')

 

Adrienne Bolger October 21, 2020

Thanks, I will look at this option.

In case it is useful for someone else, what I ended up doing in the interim since I am using Jira Server via the Atlassian Docker images was pretty simple: just setting an environment variable that I accessed with Java api in Script Runner: 

def myToken = System.getenv('MY_ENVIRONMENT_VARIABLE_API_KEY')

This solution made sense for my use case because I already had other dev/staging/production type variables for other non Atlassian Docker images stored in my Docker compose ".env" files for specific environments. Once the variables are into the Docker container for the Atlassian JIRA instance, JIRA can read them.

Like Arthur likes this
0 votes
Arthur
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.
October 21, 2020

I think the 'Script Variables' feature is only available in ScriptRunner Cloud. 

When you compare the server docs and cloud docs you see that only in the cloud docs there is the 'Script Variables' menu section on the left.

server docs: https://scriptrunner.adaptavist.com/latest/jira/quickstart.html

cloud docs: https://scriptrunner-docs.connect.adaptavist.com/jiracloud/quickstart.html?_ga=2.133944974.1895200874.1603269129-786026586.1563193409

 

however, here are some workarounds for the server (look at the last comments): https://productsupport.adaptavist.com/browse/SRJIRA-4160?_ga=2.201891345.1895200874.1603269129-786026586.1563193409

0 votes
Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 10, 2019

Hi @Jean Rodriguez 

Go into the Add-ons part of JIRA Administration and in the left sidebar there should be a sub-heading SCRIPTRUNNER with one of the subsections being Script Variables. For a Cloud instance, the exact URL should be something like this:

https://[yourinstance].atlassian.net/plugins/servlet/ac/com.onresolve.jira.groovy.groovyrunner/script-variables?s=com.onresolve.jira.groovy.groovyrunner__script-variables

Mamikon Papikyan June 4, 2020

I use scriptrunner in jira software into my localhost:8080, and there isn't Script Variables. Is there another solution?

Like Arthur likes this
Adrienne Bolger October 7, 2020

I have this problem too! Where is this field? 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events