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