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

相关推荐
鹿鸣天涯1 小时前
国产服务器操作系统迁移指南
运维·服务器
Crazy________1 小时前
40nginx从单节点 HTTPS 到集群负载均衡
linux·运维·服务器
ttthe_MOon1 小时前
LVS-NAT 模式负载均衡集群部署与配置指南
运维·负载均衡·lvs
Shylock_Mister7 小时前
Linux C线程编程全指南
linux·运维·c语言
Autism....7 小时前
服务器理解
运维·服务器
天亮之前_ict7 小时前
【故障排查】intel 服务器安装Win server 2019蓝屏解决方法
运维·服务器
熙客8 小时前
Linux:监控命令
linux·运维
飞鱼&8 小时前
Linux 常用命令
linux·运维·服务器
喵了几个咪8 小时前
使用Bazel构建你的Kratos微服务
java·运维·微服务
偶像你挑的噻9 小时前
4-Linux驱动开发-字符设备驱动
linux·运维·驱动开发