qetza / replacetokens-task

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

possibly update documentation for v6 breaking changes: tokenPattern = custom #35

Closed pietersap closed 3 months ago

pietersap commented 3 months ago

We've upgraded from v3 to v6. In the v3, we used a custom tokenPrefix and tokenSuffix, but we did not set a value for tokenPattern.

In the v6, this turned out to be broken. Here, we also need to add "tokenPattern: custom" to make it work again. This could be clarified in the list of breaking changes for v6 that I found here . The list of breaking changes is otherwise very clear, thank you.

Code before upgrade:

  - task: replacetokens@3
    displayName: 'Replace tokens'
    inputs:
      rootDirectory: ${{ parameters.rootDirectory }}
      targetFiles: ${{ parameters.targetFiles }}
      escapeType: none
      enableTransforms: true 
      actionOnMissing: fail
      tokenPrefix: ##{{
      tokenSuffix: }}##

Code after upgrade (broken)

  - task: replacetokens@6
    displayName: 'Replace tokens'
    inputs:
      root: ${{ parameters.rootDirectory }}
      sources: ${{ parameters.targetFiles }}
      escape: off
      transforms: true 
      missingVarLog: error
      tokenPrefix: ##{{
      tokenSuffix: }}##

Code after upgrade (fixed again)

  - task: replacetokens@6
    displayName: 'Replace tokens'
    inputs:
      root: ${{ parameters.rootDirectory }}
      sources: ${{ parameters.targetFiles }}
      escape: off
      transforms: true 
      missingVarLog: error
      tokenPattern: custom
      tokenPrefix: ##{{
      tokenSuffix: }}##
qetza commented 3 months ago

Hi @pietersap, Thanks for the feedback. The tokenPattern was not documented in the breaking changes because it's a breaking change from v3 to v4 :smile: Since i wrote 2 posts to help user migrate (https://github.com/qetza/replacetokens-task/discussions/33 & https://github.com/qetza/replacetokens-task/discussions/34) I'll update the readme to make it more visible (espcially if you're going from v3 to v6)