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}

Middleware Analyst specialized on IBM UrbanCode Deploy (uDeploy), WebSphere Application Server (WAS), WebSphere MQ (WMQ), *NIX systems at CSE Consorzio Servizi Bancari - Bologna, Italy

3 Replies to “Replace Tokens”

  1. Hi Gianfrancesco,
    For using Replace Tokens step, I’m reading properties from a previous step. But I only can read specific properties, not allProperties. Do you know if this is possible?

    ${p:GetMongoEnvProperties/allProperties} –> Does NOT works!
    ${p:GetMongoEnvProperties/mongo_port} –> It works!

    I’m using this sentence on “Property list” field of Replace Tokens step.


    1. Hi Rubén,
      as I wrote by email, the best solution for your needs is to use “Environment Properties” instead of “Environment Component Properties” and use ${p:environment/AllProperties} in Property List.
      Best regards.

  2. Hi Gianfrancesco
    I apologize in advance for the slight off-topic. Picking up Ruben’s example of a defined property ${p:GetMongoEnvProperties/mongo_port}, I came accross with a doubt: can I dynamically “build” this property name in a bash script?
    let’s say I have two properties defined under my Component Properties tab: ${p:component/schema01} and ${p:component/schema02}

    According to my needs I would like to invoke one or another; the problem here is that I do not know in advance if I will get the numeric code ’01’ or ’02’. I will read that code from a file and use a “if-else” statement, but I really do not want to have it harcoded.

    Question is: is there a way I can invoke my component properties with a replacement value on its name?
    Something like ${p:component/schemaCODE} , where “CODE” would contain ’01’ or ’02’.

    Of course this solution outputs the error that component property called ${p:component/schemaCODE} is not defined.
    Is this even possible?

    Thanks in advance and apologize to Ruben for using his topic.

Leave a Reply

Your email address will not be published. Required fields are marked *

eleven − ten =