You probably want to use the binding and just normal script evaluate rather than which is designed for when you don't want the full binding.

zebra_test1_list = [ 'zebra1', 'zebra2' ]
zebra_test2_list = [ 'zebra3', 'zebra4' ]

def zebras = (1..2).collect {
    evaluate("zebra_${'test' + it}_list")

assert zebras == [['zebra1', 'zebra2'],
                  ['zebra3', 'zebra4']]

Note that there is no def for the first two lines, otherwise
you are defining local variables which are normally visible
but not within the new context created when using evaluate.

Cheers, Paul.

On Thu, Mar 21, 2019 at 8:23 AM Narahari Lakshminarayana <> wrote:

Thank you in advance for your help.

I have the following groovyscript code.

def zebra_test1_list = [ "zebra1", "zebra2" ]
def zebra_test2_list = [ "zebra3", "zebra4" ]

def data="test1"
def zebra ="zebra_${data}_list")

println zebra

I get the error

groovy> def zebra_test1_list = [ "zebra1", "zebra2" ] 
groovy> def zebra_test2_list = [ "zebra3", "zebra4" ] 
groovy> def data="test1" 
groovy> def zebra ="zebra_${data}_list") 
groovy> println zebra 
Exception thrown

groovy.lang.MissingPropertyException: No such property: zebra_test1_list for class: Script1

Please help as to what I might be doing wrong.