qetza / replacetokens-task

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

transforms: true does not work #25

Open twinpiloot opened 5 months ago

twinpiloot commented 5 months ago

The release notes say that enableTransforms has been renamed to transforms. This does not seem to be true. transforms does not work while enableTransforms still work.

qetza commented 5 months ago

Hi @twinpiloot, Could you provide some logs as i have no issue using transforms in the new version 6 of the task; i also kept enableTransforms as alias in v6 to simplify upgrade.

For previous versions the input name hasn't changed.

twinpiloot commented 5 months ago

Hi, I've attached the log. Look for "##[error]variable 'upper(Infra.Environment.ShortName)' not found". After I changed it to enabledTransforms: true, it worked again.

19.txt

qetza commented 5 months ago

That's strange, could you share your the task configuration so that i can try to reproduce?

using the following pipeline

trigger: none

pool:
  vmImage: ubuntu-latest

variables:
  Infra.Environment.ShortName: infra_name

steps:
- task: replacetokens@6
  inputs:
    root: issue-25
    sources: '*.txt'
    logLevel: debug
    missingVarLog: error
    transforms: true

- pwsh: cat issue-25/config.txt

on the file

raw  : "#{Infra.Environment.ShortName}#"
upper: "#{upper(Infra.Environment.ShortName)}#"

the replace and transform are done image

and the output is as expected

raw  : "infra_name"
upper: "INFRA_NAME"
twinpiloot commented 5 months ago

This is what I had. Could it be that you are using version 6.0.5 and I 6.0.4?

qetza commented 5 months ago

The changes between 6.0.4 and 6.0.5 didn't change anything on inputs or transforms.

I've tested with this YAML and still it's working:

- task: replacetokens@6
  inputs:
    root: '$(Pipeline.Workspace)'
    sources: |
      **/issue-25/*.txt
    encoding: 'auto'
    addBOM: true
    escape: 'off'
    missingVarLog: error
    keepToken: false
    tokenPrefix: '#{'
    tokenSufix: '#{'
    transforms: true
    logLevel: debug

I though maybe it was the agent not understanding input aliases but you are using other aliases (root, sources, addBOM...) without issues.

Could you share a redacted log with system diagnostics enabled to see what are the inputs received by the task and also the azure pipelines agent version?

Also not that you should replace keepToken: false with missingVarAction: none

kipusoep commented 4 months ago

It works for me :-)