本机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

cd ....

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

ssh xxx@xxxx 'source /etc/profile; cd ...'
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐