解决Jenkins 运行shell脚本是报错,sh :command not found
2020-03-29 12:40
4975 查看
本地执行shell命令成功,Jenkins 远程执行 shell命令有时 提示命令找不到,或者make的时候报错。
因为Jenkins执行shell时无法获取环境变量的原因导致
解决办法在shell脚本上加上环境变量如
#!/bin/bash
source ~/.bash_profile
source /etc/profile
在shell脚本里面添加了后,Jenkins就能正常的运行shell脚本;
第二种解决办法:
本机shell命令可以执行,jenkins任务中无法执行,则是jenkins没有加载/etc/profile导致,需要在jenkins调用shell脚本的最前面加一行脚本,
#!/bin/bash -ilex,可以通过-i参数和-l参数让bash为login shell and interactive shell,就可以读取/etc/profile和~/.bash_profile等文件
shell脚本:
#!/bin/bash -ilex
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- 解决shell脚本错误$’r’ command not found
- shell 脚本 “bc: command not found ” 解决
- 运行脚本文件报错.sh: line 1: $'\r': command not found
- ubuntu终端执行shell脚本报command not found解决方法
- Jenkins在shell脚本运行docker权限报错解决
- shell 脚本 “bc: command not found ” 解决
- adb运行sh脚本,提示找不到文件解决方法
- Ubuntu学习总结-08 Ubuntu运行Shell脚本报 shell /bin/bash^M: bad interpreter错误问题解决
- sh下运行#!/bin/bash开头的脚本会返回not found
- ubuntu系统安装anaconda3或者miniconda3运行指令,提示sudo:conda: command not found解决办法
- Shell脚本执行时出现declare: not found的解决方法
- linux运行程序 -sh: ./xxxxx: not found 解决办法
- Linux系统中运行.sh(Shell脚本)文件
- 运行shell脚本报错 '\357\273\277': command not found 解决的方法
- shell---解决shell脚本中回车换行导致command not found
- Mac上安装mysql-mython报sh: mysql_config: command not found解决办法
- 用记事本写好的shell脚本放到linux系统运行不正常【已解决】
- Shell脚本在Linux下运行错误的解决方法
- 【Linux】运行shell脚本文件 .sh
- linux环境变量 shell变量 command not found解决方法