红联Linux门户
Linux帮助

jenkins执行shell命令,有时提示“Command not found”处理方案

发布时间:2017-02-28 11:10:13来源:linux网站作者:CoberOJ_
1、如果登录Linux,shell命令不可以执行,同样提示“Command not found”,则是环境变量设置失败,需要配置环境变量、/etc/profile
 
2、如果登录linux,shell命令可以执行,则是jenkins没有加载/etc/profile导致,需要在jenkins调用shell脚本的最前面加一行脚本,#!/bin/bash -ilex,可以通过-i参数和-l参数让bash为login shell and interactive shell,就可以读取/etc/profile和~/.bash_profile等文件,如下“
#!/bin/bash -ilex
cd..
等其他shell命令
对于e参数表示一旦出错,就退出当前的shell,x参数表示可以显示所执行的每一条命令。
 
本文永久更新地址:http://www.linuxdiyf.com/linux/28771.html