GIT: setting application environment variables

In my GIT project, I need to set a few environment variables that are required by the build scripts and many other ant objects.

Now I have a shell script that will export the variables, but every time the user opens a new bash window, he will need to repeat the steps by executing the shell script to set the environment variables.

Most of these variables are user / env specific and are checked on the fly by the shell before exporting.

If there is a way to make it more dynamic. I understand that GIT provides a hook, and one possibility is that I can use the hook to invoke the shell when the user checks out the branch.

But here again GIT keeps the current working branch, and if the user navigates to a new bash window, he will continue to be on the previously checked out branch, and he may not call the GIT checkout branch, and that will not end up calling env variables shell.

So what's the best way to handle this?

+3


source to share


1 answer


I usually use the build shell script used by the user to start the build (in the current or new shell window)

This way, environment variables are always set in every assembly.



Also, according to the version that build.sh/build.bat wrapper script is, you keep information about what parameters / environment variable your project needs to build them.
This shell script, if changed, is version checked and can be checked ( git blame

): you know who changed what and when.

+1


source







All Articles