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

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参数表示可以显示所执行的每一条命令

转自:https://blog.csdn.net/huodoubi/article/details/56845306

发布了46 篇原创文章 · 获赞 13 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/luliuliu1234/article/details/80932788
今日推荐