jenkins执行shell命令时,提示“Command not found”处理方法

jenkins执行shell命令时,提示Command not found处理方法

可能我们第一反应是查看目标机器是否已支持该命令,不过如果相信能找到这里来的朋友估计遇到的跟我一样,其实目标机器是没有问题的通过一些远程工具执行shell命令是可以执行。奇怪的就是通过jenkinsSSH插件无法执行,经一番折腾各种搜索发现是jenkins没有加载/etc/profile导致
 

解决方法很简单

#!/bin/bash -ilex
source /etc/profile

#!/bin/bash -ilex
source /etc/profile
cp target/*.jar /home/tomcat/demo
cd /home/tomcat/demo
BUILD_ID= java -jar demo-0.0.1-SNAPSHOT.jar >/dev/null/log 2>&1 &

 

おすすめ

転載: blog.csdn.net/qq_29235677/article/details/121416493