Maintain a variable array/list in a process

Hi all

I want to maintain an array of values through the execution of a process using the script / expression capabilities alone.

I have multiple messages arriving during the execution of a workflow that updates certain variables e.g. a list of email recipients. So at some stage in the process, I need to pass this array/list to a service/message task for processing.

I have tried using an execution listener end script to do this to append each new value to this array or list.

So something like:
var recipient_local = execution.getVariable(‘recipient’);
var recipients
execution.setVariable(‘recipients’, recipient_local) - I need to append or push to update the array / list.

thanks