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

相关推荐
小时候的阳光30 分钟前
Docker版Percona Xtrabackup全量压缩脚本
运维·docker·容器
4***17542 小时前
Nginx auth_request详解
运维·nginx·xcode
梦想的旅途22 小时前
企业群运营自动化:RPA技术高效赋能
运维·自动化·rpa
hhwyqwqhhwy4 小时前
Linux file->private
linux·运维·服务器
WongKyunban4 小时前
在Linux下制作软件安装包
linux·运维·服务器
hweiyu004 小时前
Linux 命令:parted
linux·运维·服务器
烽火聊员4 小时前
CertificateCreator生成服务器证书server.pfx
运维·服务器
搞全栈小苏4 小时前
Linux下 cmake所有版本适用/下载编译使用教程 附cmake3.26安装包
linux·运维·ubuntu
MyFreeIT5 小时前
Docker Manual
运维·docker·容器
F***E2395 小时前
Nginx实现接口复制
运维·nginx·junit