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

相关推荐
一条咸鱼¥¥¥2 分钟前
【运维经验】使用QQ邮箱SMTP服务器设置ssms计划任务完成时邮件发送
运维·服务器·经验分享·sql·sqlserver
【上下求索】6 分钟前
学习笔记095——Ubuntu 安装 lrzsz 服务?
运维·笔记·学习·ubuntu
Caster_Z2 小时前
WinServer安装VM虚拟机运行Linux-(失败,云服务器不支持虚拟化)
linux·运维·服务器
小小测试开发2 小时前
提升WebUI自动化效率与性能:从脚本到架构的全链路优化指南
运维·架构·自动化
GeminiJM3 小时前
Elasticsearch minimum_should_match 参数详解
大数据·elasticsearch·jenkins
The star"'3 小时前
mysql(1-3)
运维·mysql·云计算
model20054 小时前
Alibaba linux 3安装LAMP(5)
linux·运维·服务器
weixin_307779135 小时前
Jenkins中的Jakarta Activation API插件:功能、使用与最佳实践
运维·开发语言·ci/cd·自动化·jenkins
王 富贵7 小时前
【Linux】防火墙常用命令(iptables/firewalld/ufw)
linux·运维·服务器
一条咸鱼¥¥¥7 小时前
【运维经济】思科交换机和路由器的密码重置方法
运维·网络·智能路由器