How to set environment variables in Perl script to be available in BF?
![](http://jazz.net/_images/myphoto/ac37cd0f817302f1db6c1f7282660abb.jpg)
3 answers
![](http://jazz.net/_images/myphoto/ac37cd0f817302f1db6c1f7282660abb.jpg)
I think that setting environment variables in the context of the shell (which is what you are doing) will not be available to the next step, because it runs in a new shell instance.
I think that you could make it a BF_Environment Variable if you wanted to do that and use the BF Services Perl Client to set (or update the value) of it in your Perl script.
Comments
![](http://jazz.net/_images/myphoto/409d02eda675fd53138414f477c2ec0b.jpg)
Check out .tset and .bset in the help to persist variables in Build Forge builds.
![](http://jazz.net/_images/myphoto/ac37cd0f817302f1db6c1f7282660abb.jpg)
I wasn't made myself clear in the original post. This is what I did:
Step1 command: perl z:\Unix.pl SetEnvVar
The SetEnvVar() in Unix.pl will parse a long string and set each BF variable (I defined them in a BF environment attached to the BF project. This is the code: $ENV{"BANNER_H"} = $g_BANNER_H; I thought this will set system environment variable then available in BF too.
Step2, echo ${BANNER_H} is empty.
There are lots of variables, so don't want to use API to set one by one. What's wrong here?
![](http://jazz.net/_images/myphoto/ac37cd0f817302f1db6c1f7282660abb.jpg)
With less variables, I can use the API to set each of them from perl code like this: $build->updateBuildEnvEntryValue($buildEnvEntryToUpdate->getUuid(), $app_path);
Then with more than 20 variables, it's a bit messy so want to use API to set only one long and well formatted string to BF, then try to parse there and again set individual variables to BF.
I am on Windows too.