解决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 小时前
随时随地处理图片文档!Reubah 加cpolar的实用体验
linux·运维·人工智能·python·docker·开源·visual studio
iru6 小时前
kubectl cp详解,k8s集群与本地环境文件拷贝
运维·容器·k8s
摘星编程9 小时前
openGauss 快速上手:CentOS 环境下单机部署完整指南
linux·运维·centos
大喵桑丶14 小时前
中间件快速部署(Nginx,Keepalived)
运维·nginx·中间件
hanyi_qwe15 小时前
文本三剑客--awk
linux·运维·服务器
Caven7715 小时前
【Linux 技巧】如何在登录时自动激活 Conda Base 环境
linux·运维·conda
凌寒1115 小时前
Linux(Debian)安装、卸载 MySQL
linux·运维·mysql·debian
云飞云共享云桌面15 小时前
如何降低非标自动化工厂的研发软件采购成本
运维·服务器·网络·数据库·性能优化·自动化
七七墨染15 小时前
DotMemory系列:5. 如何实现自动化抓取和应用自托管
运维·c#·自动化
泰克教育官方账号15 小时前
泰涨知识 | 什么是自动化巡检?
运维·服务器·数据库