local variables in build forge steps
Hello,
I want to use a local variable in a step. My test case on linux looks like this:
x=123
echo $x
build forge transforms this to.
looks like the pre parsing needs to be turned off for variable x.
Any idea hoe to do this?
Thanx, Steffen
I want to use a local variable in a step. My test case on linux looks like this:
x=123
echo $x
build forge transforms this to.
118 29.01.14 09:30 SCRIPT x=123 119 29.01.14 09:30 SCRIPT echo xand the output is
121 29.01.14 09:30 EXEC x
looks like the pre parsing needs to be turned off for variable x.
Any idea hoe to do this?
Thanx, Steffen
2 answers
If you want to turn off the BuildForge preparsing, _NO_PREPARSE_COMMAND can be set on the environment (set to anything) and that will bypass the Build Forge parsing. Alternatively you can double up the $, like $$x, then Build Forge will interpret it down to $x, leaving the rest to the shell.
~Spencer
Hello,
I changed my code as follows:
x=123
echo $$x
echo $x
but I don't get the 123 echoed.
here is the log:
115 30.01.14 01:49 EXEC Variablenerweiterung für Befehlszeile ausführen. 116 30.01.14 01:49 SET Verweis auf nicht definierte Variable: x. 117 30.01.14 01:49 SET Verweis auf nicht definierte Variable: x. 118 30.01.14 01:49 EXEC Shell [/bin/bash] wird gestartet. 119 30.01.14 01:49 SCRIPT #!/bin/bash 120 30.01.14 01:49 SCRIPT 121 30.01.14 01:49 SCRIPT x=123 122 30.01.14 01:49 SCRIPT echo $x 123 30.01.14 01:49 SCRIPT echo x 124 30.01.14 01:49 EXEC [/home/buildforge/Library_Build/BUILD_21@bflxx861.boeblingen.de.ibm.com] starten 125 30.01.14 01:49 EXEC x 126 30.01.14 01:49 EXEC x 127 30.01.14 01:49 EXEC [/home/buildforge/Library_Build/BUILD_21@bflxx861.boeblingen.de.ibm.com] beenden 128 30.01.14 01:49 RESULT 0
Kind Regards, Steffen
Comments
You should declare the variable in the BF step using .tset or make the command runnable as one line like "x=123 && echo $$x". Otherwise the change will be lost when BF generates the new shell for the next line. The best practice here is to declare the variable in BF and not to rely on the shell variables themselves.