You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a powershell script in a stage that creates a jsonObject and I save it to a variable to be reused later:
$imagesJson = @"
[
{
"myAcr": "someCustomAcr1",
"listImages": "image1, image2"
},
{
"myAcr": "someCustomAcr2",
"listImages": "image4, image5, image6"
}
]
"@
# < some operations I do on imagesObj, already converted >
$newJson = ConvertTo-Json $imagesObj -Compress
"##vso[task.setvariable variable=ImagesList;isOutput=true]$newJson"
This part works okay. The matter is that I want to populate some YAML variables with it or iterate, for example, I want to iterate for each "dict" here and extract the info. Is that possible to do in the YAML, to populate on variables or on parameters template?
Thanks!
The text was updated successfully, but these errors were encountered:
Hi @giseliramos, because these are runtime pipeline variables, you can't use YAML template syntax (which is compile-time) with them.
More info about runtime(+macro) and compile variables and differences between them shared in this doc
Could you clarify your use case with more details? Probably we'll be able to find a suitable solution for you
The number is variable (not known before the run), so I may have $SourceAcr1, $SourceAcr2 in one run and in another run have 1 or 3, for example. That is why I tried the json to use to iterate between the keys.
In subsequent stages, I recover these variables using the stage dependencies with:
. The problem is that I want to avoid hard-coding it, like as sourceAcr1, sourceAcr2. So I need to estimate a max number, like, max 5 variables and check for each (hard-coded) if they are not empty in the "condition" of job/task.
I can get a number of the defined variables, like as numberPopulated and try to loop. It is possible to use this information and loop, like as in:
copy the numberPopulated to variables and expand as in a array, from 1 to numberPopulated
- ${{ each index in numberPopulatedArray }}:
- ${{ if eq($[stageDependencies....SourceAcr$index])}}:
- template: myCustomJob.yml
Is that possible? Or I'll need to hard-copy and check for each variable? For now, I'm doing the following for each variable, but it is cumbersome:
Hello,
I have a powershell script in a stage that creates a jsonObject and I save it to a variable to be reused later:
This part works okay. The matter is that I want to populate some YAML variables with it or iterate, for example, I want to iterate for each "dict" here and extract the info. Is that possible to do in the YAML, to populate on variables or on parameters template?
Thanks!
The text was updated successfully, but these errors were encountered: