10

我按照本教程使用 GIT 和 Maven 设置 Jenkins(稍作更改,因为我使用的是 Linux CenOS)。

我正在尝试在GitHub 的 Demo Maven 项目上测试我的设置

Jenkins 在尝试执行 Maven 时抛出异常。所以我尝试 git-clone 项目并手动运行 Maven,它工作正常。

所以问题在于 Jenkins 运行 Maven。我尝试在谷歌上搜索问题,但找不到任何有用的信息。

我目前的怀疑是:

  1. 也许 Jenkins 没有使用正确的类路径来执行 Maven。这可能是由于缺乏读取文件的权限,因为 Jenkins 在 linux 上有自己的用户(名为 jenkins)。
  2. 也许 Maven 没有正确安装。我手动安装了它,而不是让 Jenkins 为我安装它,因为我需要这个设置离线工作。

这是 Jenkins 的控制台输出:

Started by an SCM change
Building in workspace /var/lib/jenkins/jobs/Omri/workspace
Checkout:workspace / /var/lib/jenkins/jobs/Omri/workspace - hudson.remoting.LocalChannel@7ff79fae
Using strategy: Default
Last Built Revision: Revision af62f13d2374bc00a4b67f7586bfd52b7bda80eb (origin/prepare)
Fetching changes from 1 remote Git repository
Fetching upstream changes from origin
Seen branch in repository origin/HEAD
Seen branch in repository origin/master
Seen branch in repository origin/prepare
Seen 3 remote branches
Commencing build of Revision a9a1fc4a96d4ac4af3ca5e7e3b7393a6df4bf555 (origin/HEAD, origin/master)
Checking out Revision a9a1fc4a96d4ac4af3ca5e7e3b7393a6df4bf555 (origin/HEAD, origin/master)
No change to record in branch origin/HEAD
No change to record in branch origin/master
Parsing POMs
Modules changed, recalculating dependency graph
[workspace] $ /usr/java/jdk1.7.0_17/bin/java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.3.jar:/home/jenkins/maven/boot/plexus-classworlds-2.4.2.jar org.jvnet.hudson.maven3.agent.Maven3Main /home/jenkins/maven/ /var/cache/jenkins/war/WEB-INF/lib/remoting-2.24.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.3.jar 53953
<===[JENKINS REMOTING CAPACITY]===>���channel started
log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.converters.BooleanConverter).
log4j:WARN Please initialize the log4j system properly.
Executing Maven:  -B -f /var/lib/jenkins/jobs/Omri/workspace/pom.xml -Dmaven.repo.local=/var/lib/jenkins/maven-repositories/1 package
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:331)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
    at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:174)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:100)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:66)
    at hudson.remoting.UserRequest.perform(UserRequest.java:118)
    at hudson.remoting.UserRequest.perform(UserRequest.java:48)
    at hudson.remoting.Request$2.run(Request.java:326)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NoClassDefFoundError: org/apache/maven/cli/MavenLoggerManager
    at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:73)
    ... 18 more
Caused by: java.lang.ClassNotFoundException: org.apache.maven.cli.MavenLoggerManager
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
    ... 19 more
channel stopped
ERROR: Failed to parse POMs
hudson.util.IOException2: java.lang.reflect.InvocationTargetException
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:162)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:66)
    at hudson.remoting.UserRequest.perform(UserRequest.java:118)
    at hudson.remoting.UserRequest.perform(UserRequest.java:48)
    at hudson.remoting.Request$2.run(Request.java:326)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.Exception: java.lang.reflect.InvocationTargetException
    at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:177)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:100)
    ... 10 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:331)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
    at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:174)
    ... 11 more
Caused by: java.lang.NoClassDefFoundError: org/apache/maven/cli/MavenLoggerManager
    at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:73)
    ... 18 more
Caused by: java.lang.ClassNotFoundException: org.apache.maven.cli.MavenLoggerManager
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
    ... 19 more
Finished: FAILURE

任何人的想法?谢谢。

4

2 回答 2

18

显然问题是我安装了最新的 Maven alpha 版本,它是不稳定的。使用最新的稳定版本 - 3.0.5 - 一切正常。

于 2013-06-30T13:59:51.970 回答
1

这里是:

Caused by: java.lang.NoClassDefFoundError: org/apache/maven/cli/MavenLoggerManager
    at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:73)
    ... 18 more

如果您不让 Jenkins 安装 Maven,那么您需要配置它应该使用的 Maven 安装位置。

于 2013-06-30T11:13:22.423 回答