How to set environment variables in Perl script to be available in BF?
Hi
I need a perl script to manipulate the variables before next step.
In Step 1 I call a Perl script to set some system environment variables such as this: $ENV{'DIR'} = $DIR;
but in the next step $DIR is empty.
Thanks
Jirong
|
3 answers
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 Check out .tset and .bset in the help to persist variables in Build Forge builds.
Jirong Hu
commented Jun 26 '15, 10:03 a.m.
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?
Jirong Hu
commented Jun 26 '15, 10:09 a.m.
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.
|
See also my suggestions in https://jazz.net/forum/questions/95865/import-a-variable-from-a-ksh-script, which elaborate on David's and Spencer's replies.
Comments
Jojie Valiente
commented Jul 23 '13, 11:58 p.m.
Hi David,
I'm running in Windows environment. Is there another solution?
Jojie |
If you have to set a large amount of environment varuables
Create a xml project file and load it
And in the step, make all the .bset commnds needed to set everything
I am using this method to load all the CELL variables via a perl api so I can extend the project dynamicaly with a perticular cell.
|
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.