It's all about the answers!

Ask a question

While loop step, .set and environment variables value


ep zee (9695) | asked Jan 12 '11, 3:56 p.m.
In my while step I've defined a command that sets some env vars because I need to use that value on the inline library that I'm calling. The thing is, I always get the previous expected value, so: Does buildforge execute the inline project/library before the while loop command?

Command example:
.set my_env "my_var[4]=`perl my_script.pl $BF_ITERATION`"


I've tested the script's output and there's no problem there (script works ok, and the BF_ITERATION var has the correct value. I've also tried with the pass chain instead of inline but I get the same results.

3 answers



permanent link
Robert haig (1.0k16) | answered Jan 12 '11, 4:33 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
In my while step I've defined a command that sets some env vars because I need to use that value on the inline library that I'm calling. The thing is, I always get the previous expected value, so: Does buildforge execute the inline project/library before the while loop command?

Command example:
.set my_env "my_var[4]=`perl my_script.pl $BF_ITERATION`"


I've tested the script's output and there's no problem there (script works ok, and the BF_ITERATION var has the correct value. I've also tried with the pass chain instead of inline but I get the same results.


buildforge keeps it's own environment table. Your perl script (I'm assuming) is modifying the %ENV hash. This is the shell environment. When that step-part (in this case, the dot-command) is complete, that shell is terminated.

When the next step-part (or step) is started, the shell environment is set to match what is in the BF env table for that step. These values are not updated when the shell is terminated.

permanent link
ep zee (9695) | answered Jan 13 '11, 1:55 p.m.
Thanks raigh! I guess I should try something else...

What I'm trying to do is this:

(1) while (I <= total)
(2) |-- read line I from file and load values into env vars
(3) |-- call bf library A


1) Loop until all lines in my input file are processed
2) Here I want to read a given line, so the script can do some string parsing, then print the result, and finally use dot commands to load the values into my env vars
3) Call a set of steps that will use these vars I just modified

What I wrote on my previous post was (2). I had that code inside the command text box of my while step.

Any idea how can I do 1, 2 and 3 in BuildForge?

permanent link
ep zee (9695) | answered Jan 15 '11, 4:32 p.m.
I tried the same thing with the .tset command and it worked! Now I have this in the command text box of my while step:

.tset env my_env "my_var[4]=`perl my_script.pl $BF_ITERATION`"


Regards,
ep.-

Your answer


Register or 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.