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

相关推荐
Flash.kkl5 小时前
Linux——进程信号
运维·服务器
苏宸啊6 小时前
Linux权限
linux·运维·服务器
Gofarlic_oms16 小时前
Windchill用户登录与模块访问失败问题排查与许可证诊断
大数据·运维·网络·数据库·人工智能
xqhoj6 小时前
Linux——make、makefile
linux·运维·服务器
文亭湖畔程序猿7 小时前
Debian 12 日常命令 & nano 快捷键速查表
运维·debian
张童瑶7 小时前
Linux 在线安装编译Python3.11
linux·运维·python3.11
ziqibit7 小时前
debian Live with Persistence 持久化U盘的debian系统
运维·debian
Shi_haoliu7 小时前
SolidTime 在 Rocky Linux 9.5 上的完整部署流程
linux·运维·nginx·postgresql·vue·php·laravel
HIT_Weston8 小时前
100、【Ubuntu】【Hugo】搭建私人博客:元信息&翻译(一)
linux·运维·ubuntu
C_心欲无痕8 小时前
Docker 的镜像与容器
运维·docker·容器