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

相关推荐
我送炭你添花13 分钟前
树莓派部署 GenieACS 作为终端TR-069 ACS(自动配置服务器)的详细规划方案
运维·服务器·网络协议
华农第一蒟蒻20 分钟前
一次服务器CPU飙升的排查与解决
java·运维·服务器·spring boot·arthas
NGINX开源社区21 分钟前
借助 Okta 和 NGINX Ingress Controller 实现 K8s OpenID Connect 身份验证
运维·nginx·kubernetes
郝亚军1 小时前
如何在windows11和Ubuntu linux之间互传文件
linux·运维·ubuntu
j_xxx404_1 小时前
Linux:进程状态
linux·运维·服务器
济6171 小时前
linux 系统移植(第二十三期)---- 进一步完善BusyBox构建的根文件系统---- Ubuntu20.04
linux·运维·服务器
程序员 _孜然1 小时前
openkylin、ubuntu等系统实现串口自动登录
linux·运维·ubuntu
hweiyu001 小时前
Linux 命令:csplit
linux·运维·服务器
守正出琦1 小时前
Linux信号核心函数速查表
linux·运维·服务器
花花鱼1 小时前
Linux中的755及644等等速记
linux·运维·服务器