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

相关推荐
xingyuzhisuan36 分钟前
网络 Token 常见故障原理,基础排查科普
运维·服务器·网络·php
APIshop1 小时前
Python 获取 1688 商品采集 API 接口 | 工厂货源自动化对接商品信息 | 无需选品
运维·python·自动化
wljy12 小时前
二、进制状态转换
linux·运维·服务器·c语言·c++
handler012 小时前
【MySQL】常用命令总结(库与表增删查改)
运维·数据库·mysql·命令·总结
week@eight2 小时前
Linux - Doris
linux·运维·数据库·mysql
看到代码头都是大的2 小时前
CentOS环境下手动升级openssl、openssh
linux·运维·centos
浮生若城2 小时前
Linux——Ext系列文件系统
linux·运维·服务器
ITyunwei09872 小时前
主流 SaaS 工单系统对比
运维·服务器·人工智能
weixin_548444263 小时前
爆红处理APK 自动化编译流水线 v2026(英文名:APK AutoPipeline)
运维·自动化
枳实-叶3 小时前
【Linux驱动开发】第16天:按键中断完整实战
linux·运维·驱动开发