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

相关推荐
张文君4 小时前
ubuntu26.04从ext4改成mdadm的raid1+lvm启动
linux·运维·网络
DevHub5 小时前
QEMU + Busybox 搭建嵌入式 Linux 开发环境:内核编译到启动,30 秒一个迭代
linux·运维·服务器
ouynagda5 小时前
Linux 进程管理详解:从概念到实践
linux·运维·网络
2401_890603405 小时前
Linux 基础文件IO
linux·运维·服务器
tx11208763585 小时前
K8S-pod管理与控制器管理
linux·运维·kubernetes·pod
Awh-5 小时前
Linux软件应用编程 第一章中:Linux文件操作
linux·运维·服务器
adinnet20266 小时前
财务报销自动化:用智能体辅助处理繁琐报销任务
运维·自动化
zhendianluli7 小时前
VS Code Remote-SSH 连接故障排查手册(精详版)
运维·ssh
Tim风声(网络工程师)7 小时前
Kail下载
linux·运维·服务器