KBEC-00101 - Selectively suppressing property expansion

Article ID:360032831512
1 minute readKnowledge base


Property expansion by default is an all or nothing selection when you reference a property.
Properties are always expanded within the text of the commands of the shell.
If you want to set a property as the text of the property instead of the value of the property using:

ectool setProperty /myJob/noExpanded "$[stepName]"

Solution variable concatenation

In a shell

Use the syntax of the shell to defeat property expansion. For example, using a bash shell:

ectool setProperty /myJob/noExpanded "$dollar[stepName]"

In perl

Make this step an ec-perl step and in Perl, concatenate two strings

use ElectricCommander;
$ec = ElectricCommander->new();
$ec->setProperty("/myJob/noExpanded", "\$" . "[stepName]", {jobStepId => $ENV{COMMANDER_JOBSTEPID}});

Solution javascript character obfuscation

Property expansion only takes place when the syntax is contiguous. Adding escape characters defeats property expansion, so replace the first two characters with a JavaScript reference that is the equivalent:

ectool setProperty /myJob/noExpanded "$[/javascript '\x24'][stepName]"