Replace Tokens

One of the most useful thing you can do with UrbanCode Deploy  is the “replace tokens” job.  SysAdmins deal everyday  with differents environments such as DEV,  SIT, UAT, PROD. Your application needs different values like hostname, url, port, log level and much more depending on the environment where it’s deployed.

When you need to automate deployment process you must get rid of these values. With UrbanCode Deploy (uDeploy) you can create environment variables, assign values to these variables for each environment and create a component process  who will replace  tokens.

What we need is a uDeploy Server running installation, at least one uDeploy Agent and a plug-in called File Utils plug-in . Then we create a Component, an Application and one Environment. See images below:

Our goal is to automate the process of deploying a configuration to different environments. Let’s create an Environment Property Definition in our component:

Then go to Applications -> Alpha Application, Click the Environment Name (SIT), then click Configuration -> Environment Properties and assign value to the property (see figure below):

Go back to our Component and click on Processes:

Now let’s create a new process and design a flow with the steps below:

Let’s focus on the Replace Tokens step who is part of  the File Utils Plugin

The notable properties of the step are:

  • Property List
  • Start-End Token Delimiter

Property List:  Specify a property value here if you want the step to try and use existing property names  as tokens to replace in the target files. Eg: ${p:environment/allProperties} would take all component environment properties (Alpha_Url in our case) and use the property name as the token and the value as the replacement.

Delimiter:  if you have @ for start and end token delimiters and a property called token1 then the step will search for @token1@ to replace.

Other properties list are:

  • ${p:application/allProperties}
  • ${p:component/allProperties}
  • ${p:agent/allProperties}

Operations Engineer working with Cloud Infrastructure, Containers, Kubernetes, CI/CD pipelines, CDRA processes, GitOps.