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

相关推荐
知白守黑2673 小时前
Ansible角色
运维·服务器·ansible
Jwest20213 小时前
工业显示器在地铁电力监控与运维中的应用
运维·计算机外设
Mr. Cao code9 小时前
Docker:颠覆传统虚拟化的轻量级革命
linux·运维·ubuntu·docker·容器
wanhengidc10 小时前
云手机运行流畅,秒开不卡顿
运维·网络·科技·游戏·智能手机
笨小孩@GF 知行合一10 小时前
OSPF实验:外部路由引入
运维·网络·hcip·数通·ospf
asdfg125896311 小时前
为什么要在出口路由器router配置NAT与默认路由
运维·网络·计算机网络
bug攻城狮11 小时前
Skopeo 工具介绍与 CentOS 7 安装指南
linux·运维·centos
宇宙第一小趴菜11 小时前
08 修改自己的Centos的软件源
linux·运维·centos
bug攻城狮11 小时前
彻底禁用 CentOS 7.9 中 vi/vim 的滴滴声
linux·运维·服务器·centos·vim
苹果醋312 小时前
数据库索引设计:在 MongoDB 中创建高效索引的策略
java·运维·spring boot·mysql·nginx