我有一个jenkins工作,它倾向于使用maven构建我的java应用程序,但它总是在编译阶段失败。
[[1;34mINFO[m] Changes detected - recompiling the module!
[[1;34mINFO[m] Compiling 550 source files to /var/lib/jenkins/workspace/test/target/classes
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;34mINFO[m] [1;31mBUILD FAILURE[m
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;34mINFO[m] Total time: 9.575 s
[[1;34mINFO[m] Finished at: 2017-12-02T07:47:47+08:00
[[1;34mINFO[m] Final Memory: 24M/346M
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;33mWARNING[m] The requested profile "nexus" could not be activated because it does not exist.
[[1;31mERROR[m] Failed to execute goal [32morg.apache.maven.plugins:maven-compiler-plugin:3.1:compile[m [1m(default-compile)[m on project [36mtest[m: [1;31mCompilation failure[m -> [1m[Help 1][m
[[1;31mERROR[m]
我在Jenkins作业的控制台输出中找到并复制了以下命令(在网页上)。
/opt/apache-maven-3.5.0/bin/mvn -f pom.xml -s /var/lib/jenkins/test-maven-setting/setting.xml -gs /var/lib/jenkins/test-maven-setting/setting.xml -Dmaven.repo.local=/var/lib/jenkins/workspace/test/.repository clean package
然后我切换到Linux控制台中的jenkins用户并转到作业的工作区目录,并尝试手动执行我复制的上述命令。
但它成功了!
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.994 s
[INFO] Finished at: 2017-12-02T07:50:17+08:00
[INFO] Final Memory: 35M/298M
所以它非常奇怪,相同的命令,相同的用户,相同的目录,但是当我在Jenkins构建作业时手动执行它时它可以成功。有谁知道Jenkins工作失败的问题是什么?
答案 0 :(得分:0)
您在invoke-maven-targets中使用“使用默认maven设置”选项。
为默认和全局
选择“文件系统中的设置文件”选项