Code Monkey home page Code Monkey logo

vsts-replacetokens-task's Introduction

Donate

Replace Tokens task

Visual Studio Team Services Build and Release extension that replace tokens in files with variable values.

Usage

Add a new task, select Replace Tokens from the Utility category and configure it as needed.

Replace Tokens parameters

Parameters include:

  • Root directory: the base directory for searching files. If not specified the default working directory will be used.
  • Target files: the absolute or relative newline-separated paths to the files to replace tokens. Wildcards can be used (eg: **\*.config for all config files in all sub folders).
  • Files encoding: the files encoding used for reading and writing. The 'auto' value will determine the encoding based on the Byte Order Mark (BOM) if present; otherwise it will use ascii.
  • Write unicode BOM: if checked writes an unicode Byte Order Mark (BOM).
  • Escape type: specify how to escape variable values. Value auto uses the file extension (.json and .xml) to determine the escaping and none as fallback.
  • Escape character: when using custom escape type, the escape character to use when escaping characters in the variable values.
  • Characters to escape: when using custom escape type, characters in variable values to escape before replacing tokens.
  • Verbosity: specify the level of log verbosity. (note: error and system debug are always on)
  • Action: specify the action to take on a missing variable.
    • silently continue: the task will continue without displaying any message.
    • log warning: the task will continue but log a warning with the missing variable name.
    • fail: the task will fail and log the missing variable name.
  • Keep token: if checked tokens with missing variables will not be replaced by empty string.
  • Token prefix: the prefix of the tokens to search in the target files.
  • Token suffix: the suffix of the tokens to search in the target files.
  • Empty value: the variable value that will be replaced with an empty string.

Tips

If you want to use tokens in XML based configuration files to be replaced during deployment and also have those files usable for local development you can combine the Replace Tokens task with the XDT tranform task:

  • create an XDT transformation file containing your tokens
  • setup your configuration file with local developement values
  • at deployment time
    • inject your tokens in the configuration file by using your transformation file
    • replace tokens in your updated configuration file

Release notes

New in 3.2.1

  • Fix log issue with escaped secret values

New in 3.2.0

  • Switch to jschardet for encoding detection when selecting auto in File encoding (#99).
  • Switch to azure-pipelines-task-lib v2.8.0.
  • Add auto to Escape type and set it as default value.
  • Move Escape type, Escape character and Characters to escape to the main paramters section for easier discoverability.

New in 3.1.0

  • Add Verbosity parameter to allow detail logs without using system.debug.

New in 3.0.0

  • Breaking change: If you were using the character escaping feature you need to select custom in Escape values type parameter.
  • Add support to escape JSON in variable values (contributed by Justin Gould)
  • Add support to escape XML in variable values (contributed by Justin Gould)
  • Add Windows 1252 and ISO 8859-1 encoding to File encoding (#67)

New in 2.3.0

  • Add support to escape characters in variable values (#52)

New in 2.2.1

  • Fix issue with backslash in default target files value on mac (#50)

New in 2.2.0

  • Fix issue on file not found when using network paths (#40, #41).

New in 2.1.0

  • Add support for comma-separator in Target files (#35).
  • Add Empty value parameter to allow token replacement with an empty string (#32).

New in 2.0.2

  • Fix invalid file permissions after saving files.

New in 2.0.0

  • Breaking change: Migrated code to typescript to support cross-platform agent. This change requires the use of an agent at least in version 2.105.0 which is not compatible with TFS 2015. If you need to install the task on TFS 2015, download the vsix from the repository: https://github.com/qetza/vsts-replacetokens-task/releases/download/v1.4.1/qetza.replacetokens-1.4.1.vsix
  • Breaking change: File encoding parameter is now used when reading and writing files. Previously it was only used when writing.
  • Breaking change: File encoding doesn't support 'utf-32' and 'utf-32 (big endian)' anymore.
  • Breaking change: Target files parameter now only uses the new line as a separator for multi-values (previously it used new-line and semi-colon).
  • Removed required Root directory, an empty value is equivalent to $(System.DefaultWorkingDirectory).

New in 1.4.1

  • Fix missing method issue with new xplat agent (2.104.1)

New in 1.4.0

  • Add variables expansion in variable values.
  • Escape token prefix and suffix in regex pattern.

New in 1.3.1

  • Fix wrong encoding constructors parameters.

New in 1.3.0

  • Replaced parameter Fail on missing with Action in Missing variables group.
  • Add Keep token parameter in 'Missing variables' group.
  • Fix issue on empty file.

New in 1.2.0

  • Add Root directory task parameter to configure file search root directory (contributed by Jesse Houwing).
  • Update Target files task parameter to support newline-separator (contributed by Jesse Houwing).

vsts-replacetokens-task's People

Contributors

qetza avatar jessehouwing avatar skymogul avatar iorlandoni avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.