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

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

posted @ 2019-07-11 11:14  orzs  阅读(2637)  评论(0编辑  收藏  举报