开发者

BASH_ENV, or, sourcing a file in a non-interactive, non-login shell

开发者 https://www.devze.com 2023-03-07 06:49 出处:网络
I have to deploy something using Hudson, so I\'ve created a pom file for maven and the phase I\'m having it run is just some bash.

I have to deploy something using Hudson, so I've created a pom file for maven and the phase I'm having it run is just some bash.

The problem is, I have thing setup in the hudson users bashrc and/or bash_profile that are necessary for stuff to run, but those file don't seem to be sourced when running through hudson/maven. I'd really prefer to keep it running this way rather than use hardcoded stuff and absolute file paths.

I've read online that whatever is referenced in BASH_ENV is sourced for a non-interactive, non-login shell, which is what I'm guessing bash is 开发者_JAVA技巧being run as by maven/hudson.

But, BASH_ENV is empty. And, I can't set it in bashrc or bash_profile because, as I said, those aren't getting sourced, and even /etc/profile doesn't seem to be doing anything.

Is there a way I can set BASH_ENV "permanently", so that (hopefully) it will be sourced when maven runs via hudson and my various paths and such will be as they are when I'm sshing into the machine?


You have a few options. The cleanest is probably just to explicitly source the files you depend on from within your hudson bash script. That is self-documenting and clear. Otherwise, you can set BASH_ENV in the script that launches your hudson daemon and it will propagate to child processes. Check out my blog post on why environment variables are considered harmful for my case against using them.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号