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

相关推荐
HIT_Weston1 小时前
26、【Ubuntu】【远程开发】内网穿透:密钥算法介绍(二)
linux·运维·ubuntu
大地的一角3 小时前
(Linux)ELF格式与库的链接原理
linux·运维·服务器
z202305083 小时前
Linux之中断子系统-内核中断注册源码分析(4)
linux·运维·服务器
极小狐5 小时前
比 Cursor 更丝滑的 AI DevOps 编程智能体 - CodeRider-Kilo 正式发布!
运维·人工智能·devops
Sunlightʊə5 小时前
2.登录页测试用例
运维·服务器·前端·功能测试·单元测试
利刃大大6 小时前
【高并发服务器:HTTP应用】十六、HttpContext上下文模块 && HttpServer服务器模块&& 服务器测试
运维·服务器·http·高并发·项目
吃饭最爱6 小时前
Elasticsearch的用法
运维·jenkins
emiya_saber6 小时前
Linux 文件系统基本管理
linux·运维·服务器
好记忆不如烂笔头abc7 小时前
Oracle19c rac两节点实例test,在节点1查看监听状态没有test1,但在节点2可以看到test2
运维·服务器
初学者_xuan7 小时前
零基础新手小白快速了解掌握服务集群与自动化运维(十八)Ansible自动化模块--安装与入门
运维·自动化·ansible