How to Send an Environmental Value Back from a Script File
Sometimes, in order to do a complicated bit of processing, it's necessary to do it in a script file. So, if I have a step which calls some script file, and the script file computes the value of something, how do I pass that value back to Build Forge so that it can be used in subsequent steps? In the script file I've tried doing it with a "SET" command for a "real" environment variable, but Build Forge is having trouble picking it up. I'm guessing this is because the environment has already been set at the beginning of the project whereas I need this variable to be reloaded after the script executes.
Thanks,
John Bobinyec
Thanks,
John Bobinyec
One answer
The only way I have been able to figure out how to do this is to have the script write the value to a file. Then, in the next step in Build Forge, set a Build Forge environment variable to the contents of that file.
example:
Say you script ends up with the value in a UNIX variable: myValue. echo myValue to a file:
echo ${myValue} > tmpFile
Then in the next Build Forge step, set a environment variable, newValue to the contents of the file:
.bset env "newValue=`cat tmpFile`"
Kind of awkward, but it works.
example:
Say you script ends up with the value in a UNIX variable: myValue. echo myValue to a file:
echo ${myValue} > tmpFile
Then in the next Build Forge step, set a environment variable, newValue to the contents of the file:
.bset env "newValue=`cat tmpFile`"
Kind of awkward, but it works.