qetza / replacetokens-task

Azure Pipelines task to replace tokens in files with variables.
MIT License
11 stars 2 forks source link

empty values en v6 #30

Closed nuzolx closed 4 months ago

nuzolx commented 4 months ago

Hello,

I've upgraded to version 6. I want all the values to be filled in explicitly. So I use missingVarLog: 'error'. However, in some environments it is not possible to fill in a value. For me, in previous versions, I could still do this by using '(empty)' as the value, which gave '' as a replacement. Is this still possible?

qetza commented 4 months ago

Hi @nuzolx, If you want to replace missing variable with an empty value you have 2 options.

If you want to replace with an empty value without displaying any log message (use a default value):

- task: replacetokens@6
  inputs::
    sources: '**/*.json'
    missingVarAction: replace
    missingVarDefault: '' # you can omit this input as the default value is an empty string

If you want to replace with an empty value and have a log message with the level you want:

- task: replacetokens@6
  inputs::
    sources: '**/*.json'
    missingVarAction: none # you can omit this input as the default value is 'none'
    missingVarLog: error # this will make the task fail

If you need a mix based on the environment then i suggest to have a dynamic template (set the inputs based on the environment or add the 2 tasks with condition on them to be run the expected one in the expected environment)