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

相关推荐
Huangjin007_11 分钟前
【Linux 系统篇(十五)】进程 (三) :进程状态深度详解
linux·运维
RisunJan17 分钟前
Linux命令-talk(终端实时对话)
linux·运维·服务器
整点bug27 分钟前
AI 运维该不该自动执行命令?
运维·ssh·openai
Kurisu_红莉栖1 小时前
关于docker的使用心得
运维·docker·容器
三言老师1 小时前
Rocky Linux 8.6 整机系统备份与迁移方案文档文档用途
linux·运维·服务器·网络
「PlanA」1 小时前
自动化流水线CSDN自动发布文章
运维·自动化
雾时之林2 小时前
Linux----防火墙
linux·运维·网络
海兰2 小时前
【开源工具】BlueKing Lite —— AI 原生的轻量运维平台(二)
运维·人工智能·开源
fei_sun4 小时前
UVM中的TLM1.0通信
运维·服务器·uvm
MartinYeung54 小时前
[论文学习]MCPTox:面向真实世界MCP服务器的工具投毒攻击基准测试
运维·服务器·学习