问题
I'm trying to build via Jenkins but the .bash_profile $PATH additions aren't reflected when built remotely via Jenkins but in the terminal of the same user I can see them.
回答1:
Bash sources .bash_profile
only for login sessions, which a Jenkins process is not.
Put your PATH changes in .bashrc
, instead.
See also the bash manual on startup files.
回答2:
Whenever you add anything to your .bashrc
or .bash_profile
, you have to source
it. So that added variables will be available to the environment
. In your case, source ~/.bash_profile
will do the trick.
回答3:
The case could be because you launched the slave agent before making changes in Bash_profile. But Jenkins is still holding on to old values. Relaunching the slave agent could fix it as it has fixed the same issue in my case as the env was showing old parameters in profile file.
回答4:
What worked for me was reloading my tomcat server that was running Jenkins.
来源:https://stackoverflow.com/questions/48829102/jenkins-not-showing-env-set-in-from-bash-profile