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

相关推荐
xlq2232215 分钟前
30.进程池IPC
linux·运维·服务器
nuomigege29 分钟前
beagleboneblack刷入官方IOT镜像后无法运行nodered问题的处理
linux·运维·服务器
huaxiu51 小时前
ubuntu下应用打不开
linux·运维·ubuntu
m0_683124791 小时前
Ubuntu服务设置开机自启
linux·运维·ubuntu
落叶花开又一年1 小时前
检验检测机构资质认定远程评审工作程序
linux·运维·服务器
wanhengidc1 小时前
《三国志异闻录》搬砖新游戏 云手机
运维·服务器·数据库·游戏·智能手机
i建模2 小时前
通过命令行使用密钥登录远程SSH主机
运维·ssh
旺仔.2912 小时前
僵死进程及Linux文件操作 详解
linux·运维·服务器
IMPYLH2 小时前
Linux 的 comm 命令
linux·运维·算法
淡泊if2 小时前
1.2GB → 98MB,我的 Docker 镜像瘦身实战记录
运维·docker·容器