How to access all the service variables to be used as environment variable in a shell script step in Next gen ?
We can create service variables in next gen and access all of them using expression which returns a list. However if we have a use case to set all the service variable as environment variables, parsing the list can get tricky.
Below is a sample script which takes into consideration of eligible values for an environment variable and help returning them as individual values. Once the list is parsed we can use them as environment variables.
str=`echo $myvar3 | sed 's/{//g' | sed 's/}//g'`
mydel=", "
s=$str$mydel
myarr=();
while [[ $s ]]; do
myarr+=( "${s%%"$mydel"*}" );
s=${s#*"$mydel"};
done;
declare -p myarr
for i in "${myarr[@]}"
do
echo $i
done