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

相关推荐
楚疏笃12 分钟前
linux下给OpenCloudOS根目录扩容
linux·运维·服务器
dog25022 分钟前
网络的时延抖动
linux·运维·网络
程序员-Benothing40 分钟前
Linux 软件包管理:yum / apt / dnf 命令使用全解析
linux·运维·服务器
DevangLic1 小时前
opencode go要完蛋了吗
运维·学习
SEO_juper1 小时前
你的服务器正在被 AI 爬虫“白嫖“带宽:2026 用日志把 Googlebot 和 AI 洪流分开算账(附脚本)
运维·人工智能·爬虫·python·chatgpt·seo
志栋智能1 小时前
超自动化巡检报告:从数据表格到智能洞察
运维·自动化
芯飞云1 小时前
芯飞云服务器日常使用体验:从配置选型到实际负载的技术分析
运维·服务器
Splashtop高性能远程控制软件1 小时前
AI 辅助端点运维先接手补丁分级、合规可视和同台处置
运维·网络·人工智能·自动化·远程工作·splashtop
TomEval1 小时前
【接口自动化】12 - 接口自动化进阶
运维·自动化
牢姐与蒯2 小时前
Linux文件(一).前传之基础IO
linux·运维·服务器