-
Notifications
You must be signed in to change notification settings - Fork 56
Recursive Token Replacement #201
Comments
Hi @stoopered, |
Thank you! FYI your tool is awesome, and I have been using it for years! |
+1 Currently, like stoopered, I have to run two passes: the first to replace #{EnvironmentName}# and a second to replace #{dev03-password}# with the value. This would be so valuable. |
I see the merge and I tried replaceTokens@5 (and the enableRecursion: true) but I don't get the recursive replacement. Is there something I need to do for this? |
Hi @henry-padilla, |
Hi @henry-padilla, |
I'm still not seeing recursive replacement. I am using the following task:
In my variables I have the following set:
I have secrets in the key vault:
In the PSScript file I have the following:
I need the task to replace #{EnvironmentName}# with 'dev20' then replace #{dev20-ASM-Password}# with the value from the key vault. Am I doing this right? |
Hi @henry-padilla, What you can do is mixed azure pipelines recursive variables and replace tokens recursive variables like this: variables: - name: EnvironmentName
value: dev20
- name: ASM-Password
value: #{$(EnvironmentName)-ASM-Password}#
- name: AppSvc-Password
value: #{$(EnvironmentName)-AppSvc-Password}# file: $localAsmPassword = '#{ASM-Password}#'
$AppSvcPassword = '#{AppSvc-Password}#' |
That did it! |
If you have a variable library with the values:
EnvName: Dev
TestValue: #{lower(EnvName)}
test.txt would have
#{TestValue}
To Replicate/Test:
Current result: #{lower(EnvName)}
Expected result: dev
Right now the Replace Token step needs to be run multiple times to achieve the correct value. But depending on the situation, you may not know how many times to run it if you are doing multi-level replacements. It should run until no eligible replacements are found.
Solution: Add a check box to run recursive to replace nested values.
The text was updated successfully, but these errors were encountered: