I have an Azure DevOps pipeline
pool:
vmImage: 'windows-latest'
variables:
System.Debug: true
one: actual-value
Two: actual-value
MappedValue: actual-value
steps:
- task: FileTransform@2
displayName: V2 - Transform
env:
Three: actual-value
four: actual-value
five: $(MappedValue)
Six: $(MappedValue)
inputs:
folderPath: ./
jsonTargetFiles: settings.json
xmlTargetFiles: ''
xmlTransformationRules: ''
- pwsh: "Get-ChildItem Env:"
- publish: settings.json
artifact: settings.json
and the following settings.json file
{
"one":"default",
"two":"default",
"three":"default",
"four":"default",
"five":"default",
"six":"default"
}
Now I was hoping that the file transform task will be able to substitute all the value in the settings file but in reality only "one" is replaced.
Few thing to note:
So my question is what are the rules for transform task to be able to replace values in settings file? and why only one works and no other one works even they are mapped to env variables all with upper case?
Replacement is done based on the Pipeline Variable, not env variables.
Take a look on this:
pool:
vmImage: 'windows-latest'
variables:
System.Debug: true
one: actual-value
two: actual-value
MappedValue: actual-value
three: $(MappedValue)
four: actual-value
five: $(MappedValue)
Six: $(MappedValue)
steps:
- task: FileTransform@2
displayName: V2 - Transform
inputs:
folderPath: ./
jsonTargetFiles: settings.json
xmlTargetFiles: ''
xmlTransformationRules: ''
- pwsh: "Get-ChildItem Env:"
- publish: settings.json
artifact: settings.json
and I got:
{
"one": "actual-value",
"two": "actual-value",
"three": "actual-value",
"four": "actual-value",
"five": "actual-value",
"six": "default"
}
Beacuse replacement is case sensitive, six
was not replaced.