I am trying to use the task FileTransform to modify the values of grafana json templates. And it's working for modifying the values of somes keys the following way:
- task: FileTransform@2
displayName: "Transform Jsons"
inputs:
folderPath: 'metrics/dashboards/**/'
xmlTransformationRules: ''
jsonTargetFiles: '**/*.json'
And having declared the variables with the keys to substitute:
templating.list.0.query: $(azureClusterName)
templating.list.0.current.text: $(azureClusterName)
templating.list.0.current.value: $(azureClusterName)
templating.list.0.options.0.text: $(azureClusterName)
templating.list.0.options.0.value: $(azureClusterName)
If in jsonTargetFiles I only declare one file it works perfectly, but I want to know how can I assign different values for files that have the same keys.
I've tried using "replaceTokens", and having different variable names inside of the jsons files:
- task: replacetokens@3
displayName: 'Replace tokens'
inputs:
rootDirectory: 'metrics/dashboards'
targetFiles: '**/*.json'
encoding: 'auto'
verbosity: 'detailed'
actionOnMissing: 'fail'
tokenPrefix: '#{'
tokenSuffix: '}#'
But with replace tokens the template in grafana doesn't work even it says that the values have been replaced correctly.
Best