解决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

相关推荐
yyuuuzz3 小时前
AI模型部署中的常见稳定性问题
运维·服务器·网络·数据库·人工智能·云计算·github
STDD3 小时前
V Rising《夜族崛起》 专用服务器搭建教程
运维·服务器
Ameilide3 小时前
Linux 应用软件编程 多任务并发
linux·运维·服务器
无限进步_3 小时前
【Linux】环境变量:系统运行参数的“备忘录”
linux·运维·服务器
无忧.芙桃3 小时前
Linux信号机制(上)
linux·运维·服务器
utf8mb4安全女神3 小时前
怎么让服务器给自己的邮箱发消息【shell脚本】
linux·运维·服务器
ZYH_06013 小时前
BGP策略作业
运维·服务器
zhoupenghui1683 小时前
AI大模型应用部署之Flask框架使用
运维·python·docker·容器·flask·flask框架
繁星星繁4 小时前
自动化构建-make/Makefile
运维·自动化
你是个什么橙4 小时前
安装KVM服务器、使用libvirt tools工具管理虚拟机
运维·服务器·云计算