解决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 小时前
Linux的which命令
linux·运维·服务器
和小潘一起学AI1 小时前
centOS安装neo4j
linux·运维·服务器
HealthScience1 小时前
H20服务器多卡运行有错误gpu_partition ,tmux错误
linux·运维·服务器
RisunJan1 小时前
Linux命令-netstat(查看Linux中网络系统状态信息)
linux·运维·服务器
SPC的存折1 小时前
1、MySQL数据库基础
linux·运维·数据库·mysql
无忧.芙桃1 小时前
进程之环境变量
linux·运维·服务器
chxii2 小时前
linux 下用 acme.sh 搞定 Nginx 免费 SSL 证书自动续期(下) 对于acme.sh命令安装详解
linux·运维·服务器
Bert.Cai2 小时前
Linux more命令详解
linux·运维
minji...2 小时前
Linux 多线程(四)线程等待,线程分离,线程管理,C++多线程,pthread库
linux·运维·开发语言·网络·c++·算法
倔强的胖蚂蚁2 小时前
云原生服务器存储规划与磁盘选型实施
运维·服务器·云原生