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

相关推荐
工具罗某人15 小时前
docker快速部署ES
elasticsearch·docker·jenkins
ruxshui15 小时前
# Linux diff命令使用
linux·运维·服务器
Sheffield15 小时前
为什么大家都用iptables,不愿碰原生firewalld?
linux·运维·安全
何中应15 小时前
Jenkins构建完,jar包启动不起来?
linux·运维·jenkins
柏木乃一15 小时前
Linux进程信号(1):信号概述,信号产生part 1
linux·运维·服务器·c++·信号·signal
暴力求解15 小时前
Linux---进程(一):初识进程
linux·运维·服务器
risc12345615 小时前
Elasticsearch 8.x+搭建集群一 (RPM/DEB 安装方式)
安全·elasticsearch·jenkins
香蕉你个不拿拿^15 小时前
Linux中make和makefile基本使用
linux·运维·服务器
袁袁袁袁满15 小时前
Linux怎么创建Shell脚本.sh文件
linux·运维·服务器·shell·shell脚本.sh文件·创建shell脚本·创建.sh文件
唐璜Taro16 小时前
硬核实战:内网 Windows 环境下 Jenkins + Gitee 自动化部署 Vue2 项目
gitee·自动化·jenkins