Jenkins/Hudson 环境变量 [英] Jenkins / Hudson environment variables
问题描述
我正在从用户 jenkins
运行 Jenkins,该用户将 $PATH
设置为某些内容,当我进入 Jenkins 网络界面时,在系统属性 窗口 (http://$host/systemInfo
) 我看到一个不同的 $PATH
.
I am running Jenkins from user jenkins
thats has $PATH
set to something and when I go into Jenkins web interface, in the System Properties window (http://$host/systemInfo
) I see a different $PATH
.
我已经使用来自 Jenkins 网站的本机 rpm 在 Centos 上安装了 Jenkins.我正在使用安装提供的启动脚本,使用 sudo/etc/init.d/jenkins start
I have installed Jenkins on Centos with the native rpm from Jenkins website. I am using the startup script provided with the installation using sudo /etc/init.d/jenkins start
谁能向我解释为什么会这样?
Can anyone please explain to me why that happens?
推荐答案
Michael,
两件事:
当 Jenkins 连接到计算机时,它会进入 sh
shell,而不是 bash
shell(至少这是我注意到的 - 我可能错了).因此,不会考虑您在 bashrc 文件中对 $PATH 所做的任何更改.
When Jenkins connects to a computer, it goes to the sh
shell, and not the bash
shell (at least this is what I have noticed - I may be wrong). So any changes you make to $PATH in your bashrc file are not considered.
此外,您在本地 shell(您亲自 ssh 进入的 shell)中对 $PATH 所做的任何更改都不会显示在 Jenkins 中.
Also, any changes you make to $PATH in your local shell (one that you personally ssh into) will not show up in Jenkins.
要更改 Jenkins 使用的路径,您有两个选项 (AFAIK):
To change the path that Jenkins uses, you have two options (AFAIK):
1) 编辑您的 /etc/profile
文件并添加您想要的路径
1) Edit your /etc/profile
file and add the paths that you want there
2) 进入slave的配置页面,添加环境变量PATH
,值为:$PATH:/followed-by/paths/you/want/to/add
2) Go to the configuration page of your slave, and add environment variable PATH
, with value: $PATH:/followed-by/paths/you/want/to/add
如果您使用第二个选项,您的系统信息仍然不会显示它,但您的构建会看到添加的路径.
If you use the second option, your System Information will still not show it, but your builds will see the added paths.
这篇关于Jenkins/Hudson 环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!