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

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




1 vote



3 answers

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

1 vote

Comments

Check out .tset and .bset in the help to persist variables in Build Forge builds. 

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?




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.


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

0 votes

Comments

Hi David,

I'm running in Windows environment. Is there another solution?

Jojie


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

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,023

Question asked: Sep 21 '12, 5:03 p.m.

Question was seen: 14,092 times

Last updated: Jun 26 '15, 10:09 a.m.

Confirmation Cancel Confirm