解决Jenkins 运行shell脚本是报错,/bin/sh: line 1: allure: command not found

解决Jenkins 运行shell脚本是报错,/bin/sh: line 1: allure: command not found

本地执行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

相关推荐
小豆子范德萨1 小时前
cursor连接远程window服务器的WSL-ubuntu
运维·服务器·ubuntu
夜月yeyue7 小时前
Linux 调度类(sched_class)
linux·运维·c语言·单片机·性能优化
林义满8 小时前
运维转型让产线 “少掉链”:上海义满汽车零部件借智能运维降本增效,年减损失超 200 万
运维·汽车
VekiSon8 小时前
Linux系统编程——IPC进程间通信:信号通信与共享内存
linux·运维·服务器
南山nash8 小时前
CentOs7 安装 Docker 详细步骤
linux·运维·docker·容器
ZHHHHHJ669 小时前
LL层-PAST
运维·服务器·网络
fufu03119 小时前
Linux环境下的C语言编程(四十六)
linux·运维·服务器
qq_4182478810 小时前
Linux上部署conda环境
linux·运维·神经网络·机器学习·conda
行走的领路人11 小时前
同步服务器时间
运维·服务器
_F_y12 小时前
Linux:多线程
linux·运维·服务器