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

相关推荐
热爱编程的小白白9 小时前
【Playwright自动化】录制生成脚本
运维·自动化
java_logo9 小时前
MySQL Server Docker 容器化部署指南
linux·运维·数据库·docker·容器
I***t7169 小时前
自己编译RustDesk,并将自建ID服务器和key信息写入客户端
运维·服务器
star_11129 小时前
Jenkins+nginx部署前端vue项目
前端·vue.js·jenkins
BJ_Bonree9 小时前
数智先锋 | 核心应用响应时常<1s、多终端崩溃率低至 0.1%!Bonree ONE 赋能蓝月亮应用性能与终端体验双重升级!
运维
张鱼小丸子9 小时前
电脑刷机教程:轻松重装系统指南
运维
k***1959 小时前
Nginx反向代理出现502 Bad Gateway问题的解决方案
运维·nginx·gateway
可爱又迷人的反派角色“yang”9 小时前
LVS+Keepalived群集
linux·运维·服务器·前端·nginx·lvs
hadage23310 小时前
--- docker 一些指令的汇总 ---
运维·docker·容器
好奇的菜鸟10 小时前
WSL 2 安装 Ubuntu 24.04 及系统迁移到非系统盘
linux·运维·ubuntu