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

相关推荐
公众号:fuwuqiBMC5 小时前
(转自“服务器BMC”)服务器BMC芯片——多Die(芯片)封装
运维·服务器·人工智能
D2aZXN3FhrDa7e2127 小时前
佛山乐从低预算实体店如何选择?看美诚AI自动化获客方案
运维·人工智能·自动化·佛山美诚科技有限公司
无足鸟ICT7 小时前
【RHCA+】查看变量
linux·运维·服务器
Kina_C7 小时前
Linux DNS 服务器-从高速缓存到辅助 DNS 部署指南
linux·运维·服务器·dns
suaizai_8 小时前
TypeScript 7 正式发布!Vue 暂被 “拒之门外“ !!!
linux·运维·ubuntu
慕伏白9 小时前
【慕伏白】Linux 系统如何根据端口号关闭进程
linux·运维·服务器
letisgo59 小时前
VMware Workstation + Ubuntu 26.04 LTS 小白运维部署手册
linux·运维·ubuntu
蓝创工坊Blue Foundry9 小时前
图片文字提取到 Excel:批量任务如何先定义要交付的字段
运维·服务器·开发语言·数据库·自动化·ocr·excel
晚风吹长发9 小时前
Docker使用——Docker容器及相关命令
linux·运维·服务器·docker·容器·架构
ShiXZ2139 小时前
Docker Compose 安装与配置指南
运维·docker·容器