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

相关推荐
952363 小时前
Docker - 基础
运维·后端·docker·容器
Promise微笑3 小时前
智能激光清障仪选型指南:高效运维与安全保障的关键考量
运维·安全
Code_Ignis3 小时前
docker国内可用源(持续维护)
运维·docker·容器
一叶龙洲3 小时前
向日葵远程Ubuntu,支持隐私屏
linux·运维·ubuntu
Jerry小杰9 小时前
运维神器|单端口搞定多台内网SSH!frp端口复用终极教程
运维·ssh
Python私教10 小时前
Blender模型导入Godot完整教程:GLB、BLEND与继承场景怎么选
运维·godot·blender
AOwhisky10 小时前
Linux(CentOS)系统管理入门笔记(第十二期)——系统管理工具与软件包管理(上篇):Cockpit 与 RPM 包管理
linux·运维·笔记·centos·云计算
糖果店的幽灵11 小时前
langgraph的流式执行
linux·运维·服务器·人工智能·langgraph
运维大师12 小时前
【K8S 运维实战】15-链路追踪Jaeger与OTel
运维·容器·kubernetes
霁月的小屋13 小时前
Docker 工程化实践(二):理解镜像分层与容器文件系统
运维·docker·容器