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

相关推荐
澜山奕秋43 分钟前
Rhcsa 二
linux·运维·服务器
无足鸟ICT1 小时前
【RHCA+】yum源配置(软件仓库)
linux·运维
dk_tjy1 小时前
迪康加密系统技术解析:驱动层透明加密的机制、策略与工程权衡
运维·安全·网络安全·终端安全管理·数据防泄漏
Initialize-le2 小时前
服务器时间不准?NTP 时钟同步五步排查
运维·服务器
AR-26710-2 小时前
Linux Day24——TCP/IP分层与封装
linux·运维
m0_617493942 小时前
昇腾 NPU Docker 部署实战:解决 stub library 报错并实现模型正常加载
运维·docker·容器
小羊没烦恼!2 小时前
.NET 11 Runtime Async 详解
java·运维·开发语言·javascript·python
Geek-Chow2 小时前
Building and Using a Jenkins Shared Library
jenkins
xianyuCcCcCCCcc3 小时前
Ceph 分布式存储:集群配置与存储池管理
运维·分布式·ceph
爬也要爬着前进4 小时前
Prometheus通过Nginx-vts-exporter模块监控nginx服务
运维·nginx·prometheus