qetza / replacetokens-task

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

Upgrade question #26

Closed DomBurf closed 2 months ago

DomBurf commented 5 months ago

I am looking to upgrade from v3 to v5 or v6

I see that there is a new mandatory property called tokenPattern. We currently use this Task for .json, .tfvars, *.properties etc files.

I use the Task inside a Task Group that is consumed by multiple file types across different pipelines (.NET, Terraform etc)

I'm not sure what to enter for this new property. Any advice?

qetza commented 5 months ago

Hi @DomBurf, The tokenPattern input was added to "replace" tokenPrefix and tokenSuffix for common values.

Here is a table with the correspondance: tokenPrefix tokenSuffix tokenPattern Comments
#{ }# default you can remove tokenPrefix and tokenSuffix inputs
$( ) azpipelines you can remove tokenPrefix and tokenSuffix inputs
{{ }} doublebraces you can remove tokenPrefix and tokenSuffix inputs
__ __ rm only for v5, you can remove tokenPrefix and tokenSuffix inputs
__ __ doubleunderscores only for v6, you can remove tokenPrefix and tokenSuffix inputs
#{ } octopus you can remove tokenPrefix and tokenSuffix inputs
${{ }} githubactions only for v6, you can remove tokenPrefix and tokenSuffix inputs
other other custom keep tokenPrefix and tokenSuffix inputs
tdotcdot88 commented 4 months ago

@qetza thanks for the response I am running into an issue as well. Below is how we had the task

  # Replace secret token
  - task: replacetokens@3
    inputs:
      targetFiles: '$(TEMPLATE_FILE)'
      keepToken: false
      tokenPrefix: '#{'
      tokenSuffix: '}#'
    displayName: 'Replace secret token'

Would my new version look like this

** # Replace secret token

qetza commented 4 months ago

Hi @tdotcdot88, I've just added 2 pinned discussions to explain how to migrate:

In you case the correct syntax would be:

- task: replacetokens@6
  inputs:
    sources: '$(TEMPLATE_FILE)' # make sure your path uses slashes and not backslashes
    missingVarAction: none      # this the default value so you can omit the input
    missingVarLog: warn         # this the default value so you can omit the input
    tokenPattern: default       # this the default value so you can omit the input
  displayName: 'Replace secret token'