Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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.
118	29.01.14 09:30		SCRIPT	x=123
119	29.01.14 09:30		SCRIPT	echo x
and 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

 

0 votes



2 answers

Permanent link
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

0 votes


Permanent link
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

0 votes

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.

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,020

Question asked: Jan 29 '14, 10:45 a.m.

Question was seen: 5,039 times

Last updated: Jan 30 '14, 8:24 a.m.

Confirmation Cancel Confirm