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

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

0 votes



2 answers

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


0 votes


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

0 votes

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,026
× 10

Question asked: Jun 26 '15, 4:28 p.m.

Question was seen: 4,906 times

Last updated: Jun 29 '15, 10:03 a.m.

Confirmation Cancel Confirm