Last Array Variable in scope skipped

I have the following code in my deployment:

#{each SecureVariable in Global_SecureVariable}
value="#{SecureVariable.Value}"
value="${value%"}"
value="${value#"}"
if [ -n “$value” ] && [ “$value” != “” ]; then
if grep -q ‘^#{SecureVariable.Variable}’ $filename; then
sed -i ‘/^#{SecureVariable.Variable}/c#{SecureVariable.Variable}=#{SecureVariable.Value}’ $filename
else
tee -a $filename <<< “#{SecureVariable.Variable}=#{SecureVariable.Value}”
fi
fi
#{/each}

I have the following variables store in a library set:
Global_SecureVariable[host].Variable = securehub.host
Global_SecureVariable[host].Value = xxxxyyyy

Global_SecureVariable[password].Variable = securehub.password
Global_SecureVariable[password].Value = zzzddd

Global_SecureVariable[username].Variable = user
Global_SecureVariable[username].Value = afrearo35

All the Variables with .Value has scope Environment to “INT”

When run the script it return the following to the file:
securehub.host=xxxxyyyy
securehub.password=zzzddd
securehub.username=#{SecureVariable.Value}

I ran another test where I removed the scope from Global_SecureVariable[username].Value and this work as expected.

I ran another test where I add a second Global_SecureVariable[username].Value with no scope. This too ran OK in my INT environment. I’ve used this as a work around.

Can you please review the issue.

btw I’m runnin 2018-06-15

Hi Binh,

I’ve setup a local test project on 2018.6.15 with your script and a library variable set with the variables you mentioned (adding an environment scope to the .Value variables) but I can’t replicate the issue you are seeing.

Step:

Library variable set:

Deployment:
image

File output on target:
image

What OS is your deployment target running? I was using Ubuntu 16.04 in my testing.

Thank you and kind regards,
Henrik

Hi,

Please set all variable .Value to have variable type Sensitive and run your test again.

I can confirm we are also running Ubuntu 16.04

Regards

Binh

Hi Binh,

I changed the .Value variables to sensitive variables but I still get the same result.

image

image

Can you double check the scoping of your variables in the variable set.

Thank you,
Henrik

Can you please try using random special characters in the value.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.