It's all about the answers!

Ask a question

How to set environment variables in external Perl script to be available in Buildforge step?


Jirong Hu (1.5k9290258) | asked Jun 26 '15, 4:28 p.m.
I know I've asked this many times, but I still haven't figured out why. This is what I want to do:
1. I create an environment variable in BF called APP_NAME
2. In the first BF step command, I call this "perl Z:\Unix.pl SetEnvVar". Inside SetEnvVar(), I have this line of code, ENV{APP_NAME}=UARK;
3. In the next BF step, when I try to print ${APP_NAME}, it's empty.

I thought the second step will create a system environment called APP_NAME and assign the value UARK, and this will be automatically assigned to the same variable defined in APP_NAME. What's wrong here?

If this doesn't work, I'll have to try David's solution: bset env "var1=`get_var_value.pl file=the_stuff.txt varname=TAR_FILE`" https://jazz.net/forum/questions/95865/import-a-variable-from-a-ksh-script

Thanks
Jirong

2 answers



permanent link
Kevin Ramer (4.5k8183200) | answered Jun 26 '15, 4:51 p.m.
In most "shell" run-time environments, environment variables set in some process will only be visible to child processes ( i.e. processes explicitly launched by a process ).   The steps are typically run in a shell on the bf agent as a child process still bound by the parent/child relationship.



permanent link
Spencer Murata (2.3k115971) | answered Jun 29 '15, 10:03 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
 Build Forge intentionally blanks out the existing machine variables when running the BFA shell as it would interfere with the consistent running of builds.  Only those variables set in Build Forge are populated into the shell.  That is why the .bset solution works as it adds the variable to the BF environment.

So .bset is the most correct solution for this particular use case.

~Spencer

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.