jenkins执行shell命令时,提示“Command not found”处理方法-需要在jenkins调用shell脚本的最前面加一行脚本, #!/bin/bash -ilex-------转载

原文:https://blog.csdn.net/yule09/article/details/86537652

本机shell命令可以执行,jenkins任务中无法执行,则是jenkins没有加载/etc/profile导致,

需要在jenkins调用shell脚本的最前面加一行脚本,

#!/bin/bash -ilex

可以通过-i参数和-l参数让bash为login shell and interactive shell,

就可以读取/etc/profile和~/.bash_profile等文件

#!/bin/bash -ilex

ifconfig

------以下这部分我暂时没有用到-------

ssh命令中可以直接添加 source /etc/profile

ssh xxx@xxxx 'source /etc/profile; ifconfig'
原文地址:https://www.cnblogs.com/yiyaxuan/p/14822082.html