Fetch global variable value through Jython API

Hi Team,

Here’s the script to fetch values for particular global variable(list type).

mylist = configurationApi.getGlobalVariable("Variable07f0a92bde9d44e5b0617e51630f759c")
print mylist

Getting below error:

Exception during execution:
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: ID 'Variable07f0a92bde9d44e5b0617e51630f759c' does not contain prefix 'Release' in <script> at line number 1

What am I missing? Please suggest.


Hi trojan3107,
the “trick” is not to use config api, there is a special jython dictionary named ‘globalVariables’ which contains all the global vars from one server
Code sample for a jython script task, global.demoNumber is difeed as global var (under settings -> global Variables)

print "global demo var"
demoNumber = globalVariables['global.demoNumber']
print demoNumber

Hi @mzieger

Thanks for your pointers. I’ve already used the script as you suggest and it works fine in jython script task.

In my case, I am using “xlr-custom-report-plugin-1.0.3.jar” community plugin. (https://github.com/xebialabs-community/xlr-custom-report-plugin)

And in this case, I’m defining the script in “Shared Configuration > Report:Custom report”, but when I excute , it throws below error (see ss). This plugin should work based on jython script.
So, I thought of using config API instead.

Error while executing script [jar:file:/C:/XL%20Install/xl-release-9.7.5-server/xl-release-9.7.5-server/plugins/__local__/xlr-custom-report-plugin-1.0.3.jar!/restapi/generatereport.py]: NameError: name 'globalVariables' is not defined in <script> at line number 13

Here’s the script defined in shared config > Report: CustomReport

May be I’m missing something here or there is issue in community plugin.

Please have a look.


you need to import something into the script and also call it different from another plugin, not from Jython task type , please have a look here:https://github.com/xebialabs-community/xlr-semaphore-plugin, they also use the global vars from a jython script in a different plugins