异常: failed to run command ‘java’: No such file or directory 解决.

场景: Jenkins 远程部署 Java工程.

异常: 文件已正常远程传输到远端服务器, 在最后执行运行脚本时, 出现标题的异常.

排查: 该脚本是正常的, 在远程服务器已经正常测试过了, 是root权限, 现在用Jenkins也是root权限, 怎么看都不会出现问题才对.

  • 实际的经过可以用下面这段英文来描述:

How it happened: When I was using Jenkins to remotely deploy a Java project, I could not find the Java command. I was executing a Shell script. The reason was that I could not read the user's environment variable when executing a Shell command remotely. To use environment variables, you need to re-execute the 'source /etc/profile' command before invoking the Java command in the script.

用英文翻译一下, 加深印象, 以前遇到过类似的问题, 所以看到报错信息, 很快解决了, 也给没遇到过类似情况的小伙伴一个提醒.

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容