当与另一个项目一起使用的相同脚本工作正常时,Jenkins 管道找不到 Java

Jenkins pipeline unable to find Java when same script used with another project is working fine

提问人:Sachin Sheelavant 提问时间:11/17/2023 更新时间:11/17/2023 访问量:20

问:

我收到以下错误

[INFO] Changes detected - recompiling the module! :dependency
[INFO] Compiling 7 source files with javac [debug target 1.8] to target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  36.513 s
[INFO] Finished at: 2023-11-16T05:23:59Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project project-name: Fatal error compiling: tools.jar not found: /usr/lib/jvm/java-8-amazon-corretto/../lib/tools.jar -> [Help 1]

我检查了管道中的 java 版本,它正确显示如下

[Pipeline] sh
+ java -version
openjdk version "1.8.0_392"
OpenJDK Runtime Environment Corretto-8.392.08.1 (build 1.8.0_392-b08)
OpenJDK 64-Bit Server VM Corretto-8.392.08.1 (build 25.392-b08, mixed mode)
[Pipeline] sh
+ javac -version
javac 1.8.0_392

可能是什么问题?

java maven jenkins jenkins-pipeline

评论

0赞 Rob Spoor 11/17/2023
这看起来很奇怪,因为这会将文件解析为 .也许 Java 安装有问题。它是手动安装的,还是通过 Jenkins 本身安装的?../lib/tools.jar/usr/lib/jvm/lib/tools.jar
0赞 Sachin Sheelavant 11/28/2023
它是通过基于 amazon corretto jdk8 映像的构建从属设备完成的
0赞 Rob Spoor 11/28/2023
这是使用 Jenkins 工具管理安装的?你能确保那里的文件夹设置正确吗?

答: 暂无答案