How to set environment variables in external Perl script to be available in Buildforge step?
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
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.
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.
~Spencer
So .bset is the most correct solution for this particular use case.
~Spencer