jenkins - For Loop to call multiple variables from properties file -


i have properties file call inside jenkins pipeline script multiple variables.

buildcounter = n buildname1 = name 1 buildname2 = name 2    ... buildnamen = name n 

i call properties file with: def props = readproperties file: path

now want create loop print buildnames

for (i = 0; < buildjobcounterint; i++){             tmp = 'buildname' + i+1             println props.tmp } 

but of course not working. ne last println call searching variable called tmp in properties file. there way perform or wrong?

edit:

this .properties file:

buildjobcounter = 1 buildname1 = 'win32' buildpath1 = '_build/mbe3_win32' buildname2 = 'empty' buildpath2 = 'empty'  testjobcounter = '0' testname1 = 'empty' testpath1 = 'empty' testname2 = 'empty' testpath2 = 'empty'      

in jenkins pipeline want have possibility check ammount of build/testjobs , automatically calle jobs (each buildname , buildpath freestyle job) call these job thought of calling variables inside loop. every istep have name/path pair.

try below:

change from:

println props.tmp 

to:

println props[tmp] 

or

println props."$tmp" 

edit : based on op comment

change from:

tmp = 'buildname' + i+1 

to:

def tmp = "buildname${(i+1).tostring()}" 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -