在jenkins shell 排查一个错误时,花了很久。

表象是因为 执行shell 脚本 中的 java -jar xxx.jar 没有成功启动jar 程序。

因为使用了 nohup & 来后台启动jar 包,所以jenkins 没有打印出错误 日志。

在去除 nohup & 之后,发现是报了error unable to access jarfile 错误导致的。

解决方案:发现是 调用shell脚本 时访问不到该jar,通过修改jar 绝对路径解决了

/home/user01/tool/traffic_broker_monitor

echo "launch monitor tool"
echo "bash /home/user01/tool/test_monitor.sh $monitor_connectors $project $region"
sshpass -p ${PWD} ssh ${USERNAME}@${IP} "bash /home/ser01/tool/test_monitor.sh $monitor_connectors $project $region"
java -jar broker_monitor.jar 
--num=$1 
--target_server=k8s.mypna 
--data_source=HERE-HERE-SEA --receiver=\{\"redis_cluster_address\":\"mypna\",\"redis_port\":6379\}

更多推荐

error unable to access jarfile 解决方案