Use Precondition in uDeploy

Most steps in a process can have a precondition. The precondition determines whether the step runs.

Preconditions return Boolean values. If the precondition returns True, the step runs as usual. If the precondition returns anything other than True, the process skips that step.

Suppose we need to create a symlink but only under certain conditions. We create a Shell step:

where the script code to execute will be something like this:

ln -fs ${p:environment/ALPHALib_Path}/${p:version/shlib-alphalibrary} ${p:environment/shlib_path}/ALPHALibrary

where

environment/ALPHALib_Path = /var/shlib/ALPHALibrary
version/shlib-alphalibrary = v20170713_5_12
environment/shlib_path = /var/cfg/alpha-resources/shlib
ln -fs /var/shlib/ALPHALibrary/v20170713_5_12 /var/cfg/alpha-resources/shlib/ALPHALibrary

We want to execute the shell script only if the property1 exist. Here’s the syntax:

properties.get("environment/property1") !== undefined && 
properties.get("environment/property1") !== null && 
properties.get("environment/property1") !== ""

To access a property we use the properties.get() command. Do not use notation such as ${p:component.myProperty} in the precondition script. For example, to check the value of a component property in a component process, use properties.get(“myProperty”) == “myValue”.

Let’s see further examples:

Do you need to add a Shared Library to a WebSphere Application Server Application just for one environment? We can use the Precondition:

properties.get("environment.name") == "DEV"

Want to modify Context Root Web Modules for different Application Name?

properties.get("application.name") == "ALPHA_APP"

DevOps Engineer specialized on IBM UrbanCode Deploy (uDeploy) and IBM WebSphere Application Server (WAS) at CSE Consorzio Servizi Bancari - Bologna, Italy