I came across a scenario, where I need to create an Array variable or a list. The values which I am expecting are of type String
I am getting those individual values inside the loop (Variable1 in the below code). I want to set those values as a variable (arrayVariable in the below code) so that I can use those values in different tasks or templates.
variables:
- name: arrayVariable
value:
steps:
- powershell: |
## Some Other Conditional Code
For ($i=0; $i -lt $temp.Length; $i++)
{
$Variable1=$temp[$i]
echo "this is $Variable1 value" ## Here I can have multiple values on the basis of loop
## This value i want to keep in Array or in List to reffer it another task/templates.
Write-Host "##vso[task.setvariable variable=arrayVariable]$Variable1"
echo "Variable's value in loop $Variable1"
}
displayName: 'Powershell Task'
Please let me know if the creation of the list or array is possible at runtime.
Any Help | Guidance will be appreciable.