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

相关推荐
ITOWARE_SAPer14 小时前
选择SAP实施公司能否兼得官方授权与高性价比?
运维·能源·制造·零售
Elastic 中国社区官方博客14 小时前
Elasticsearch:快速近似 ES|QL - 第一部分
大数据·运维·数据库·elasticsearch·搜索引擎·全文检索
AC赳赳老秦15 小时前
OpenClaw生成博客封面图+标题,适配CSDN视觉搜索,提升点击量
运维·人工智能·python·自动化·php·deepseek·openclaw
Eric.Lee202116 小时前
docker 启动停止命令
运维·docker·容器
samson_www16 小时前
EC2的GRUB引导程序问题
运维·ai
代码中介商17 小时前
Linux 帮助手册与用户管理完全指南
linux·运维·服务器
weixin_4491736519 小时前
Linux -- 项目中查找日志的常用Linux命令
linux·运维·服务器
深念Y20 小时前
赛米尼M02/海纳斯HiNAS系统-WiFi驱动安装教程
运维·服务器·网络·docker·nas·机顶盒·hinas
会飞的土拨鼠呀20 小时前
Ubuntu24.04安装open-vm-tools
运维·服务器