Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transforms: true does not work #25

Open
twinpiloot opened this issue Mar 26, 2024 · 6 comments
Open

transforms: true does not work #25

twinpiloot opened this issue Mar 26, 2024 · 6 comments

Comments

@twinpiloot
Copy link

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
Copy link
Owner

qetza commented Mar 26, 2024

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
Copy link
Author

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
Copy link
Owner

qetza commented Mar 26, 2024

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
Copy link
Author

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

  • task: replacetokens@6
    displayName: 'Tokenize Configuration files and PowerShell scripts'
    inputs:
    root: '$(Pipeline.Workspace)'
    sources: |
    **/.ps1
    **/
    .json
    encoding: 'auto'
    addBOM: true
    escape: 'off'
    missingVarLog: 'error'
    keepToken: false
    tokenPrefix: '#{'
    tokenSuffix: '}#'
    transforms: true

@qetza
Copy link
Owner

qetza commented Mar 27, 2024

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
Copy link

kipusoep commented Apr 9, 2024

It works for me :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants