Maven 构建在 Jenkins 上失败,但可以在本地计算机上运行

标签 maven jenkins continuous-integration maven-3

我有一个全新安装的 Debian Wheezy 服务器,运行从 official deb package 安装的 Jenkins 1.596(最新版本)。 .

为了使用 Jenkins,我创建了一个新的 Maven-Project,它可以通过 Git 进行检查。

当我运行 Maven 来构建此项目时,在安装了 Maven 版本 3.0.5 的本地计算机上,通过执行 mvn3 package 构建成功,但是当我尝试在Jenkins 服务器构建失败。

插件 maven-resources-plugin (maven-resources-plugin:2.6) 和 maven-compiler-plugin (maven-compiler-plugin:2.5.1) 在我的开发系统和 Jenkins 服务器上是相同的版本。

由于错误:找不到符号错误而导致构建失败,在我的本地系统上构建项目时不会发生该错误。

这是 Jenkins 服务器在构建过程中生成的日志:

Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/hidden/workspace
 > /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > /usr/bin/git config remote.origin.url ssh://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="284f415c685a4d4c0640414c4c4d464b474558494651064b4745" rel="noreferrer noopener nofollow">[email protected]</a>/srv/gitosis/repositories/hidden.git # timeout=10
Fetching upstream changes from ssh://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="294e405d695b4c4d0741404d4d4c474a464459484750074a4644" rel="noreferrer noopener nofollow">[email protected]</a>/srv/gitosis/repositories/hidden.git
 > /usr/bin/git --version # timeout=10
using GIT_SSH to set credentials 
 > /usr/bin/git -c core.askpass=true fetch --tags --progress ssh://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2d4a44596d5f4849034544494948434e42405d4c4354034e4240" rel="noreferrer noopener nofollow">[email protected]</a>/srv/gitosis/repositories/hidden.git +refs/heads/*:refs/remotes/origin/*
 > /usr/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > /usr/bin/git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 0d5334724d01ec42ed23912f687eb412997eede8 (refs/remotes/origin/master)
 > /usr/bin/git config core.sparsecheckout # timeout=10
 > /usr/bin/git checkout -f 0d5334724d01ec42ed23912f687eb412997eede8
 > /usr/bin/git rev-list 0d5334724d01ec42ed23912f687eb412997eede8 # timeout=10
Parsing POMs
[workspace] $ /var/lib/jenkins/tools/hudson.model.JDK/JDK_7/bin/java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven32-agent-1.6.jar:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/boot/plexus-classworlds-2.5.1.jar:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/conf/logging jenkins.maven3.agent.Maven32Main /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven /var/cache/jenkins/war/WEB-INF/lib/remoting-2.49.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven32-interceptor-1.6.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.6.jar 55526
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven:  -B -f /var/lib/jenkins/jobs/hidden/workspace/pom.xml package
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building hidden 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hidden ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ hidden ---
[INFO] Compiling 15 source files to /var/lib/jenkins/jobs/hidden/workspace/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /var/lib/jenkins/jobs/hidden/workspace/src/main/java/com/logicsale/hidden/aggregator/provider/hiddencompany/AmazonSellerRatingsProvider.java:[41,58] error: cannot find symbol
[INFO] 1 error
[INFO] -------------------------------------------------------------
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.745 s
[INFO] Finished at: 2015-01-14T09:32:55+01:00
[INFO] Final Memory: 16M/39M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project hidden: Compilation failure
[ERROR] /var/lib/jenkins/jobs/hidden/workspace/src/main/java/com/logicsale/hidden/aggregator/provider/hiddencompany/AmazonSellerRatingsProvider.java:[41,58] error: cannot find symbol
[ERROR] -> [Help 1]
[ERROR] 
[JENKINS] Archiving /var/lib/jenkins/jobs/hidden/workspace/pom.xml to com.logicsale.hidden/hidden/1.0-SNAPSHOT/hidden-1.0-SNAPSHOT.pom
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
channel stopped
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: FAILURE

我尝试使用 JDK7 和 JDK8 构建都失败了。

最佳答案

请看看这个question和接受的答案。也许是bug在 maven-compiler-plugin 中 - 尝试将 maven-compiler-plugin 的版本更新到 3.1 或更高版本。

关于Maven 构建在 Jenkins 上失败,但可以在本地计算机上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27941268/

相关文章:

docker - 如何在 kubernetes 内运行的 jenkins 管道中运行 sidecar 容器

git - 我如何在 Jenkins 中克隆一个工作?

jenkins - 让 Jenkins 使用可变 SVN URL 构建多个配置

testing - 在 Kubernetes 堆栈上运行集成/e2e 测试

java - Spring 工具套件 - ClassNotFoundException : oracle. jdbc.driver.OracleDriver

java - Maven 多模块 : error assembling WAR: webxml attribute is required

maven - 异常发生在测试用例结束时

ios - 持续集成,如何为 QA 和 App Store 发布生成单个构建(二进制)?

多模块项目上的 Maven 站点无法解决依赖关系

Maven Pom.xml问题