我认为我已经设置了与Maven一起运行jenkins工作所需的外包,但每次我的工作时我都会遇到错误。 我使用的是Ubuntu 14.04 LTS和Jenkins 1.642。
完整错误:
Parsing POMs
[RaceCom] $ /var/lib/jenkins/tools/hudson.model.JDK/JDK/bin/java mvn --batch-mode release:update-versions -DdevelopmentVersion=1.2.0-SNAPSHOT -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-agent-1.5.jar:/home/damian/Documents/apache-maven-3.3.9/boot/plexus-classworlds-2.5.2.jar:/home/damian/Documents/apache-maven-3.3.9/conf/logging jenkins.maven3.agent.Maven31Main /home/damian/Documents/apache-maven-3.3.9/ /var/cache/jenkins/war/WEB-INF/lib/remoting-2.53.3.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-interceptor-1.5.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.5.jar 50845
Error: Could not find or load main class mvn
ERROR: Failed to launch Maven. Exit code = 1
Java Home环境变量和版本检查:
damian@damian-server:~$ echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle
damian@damian-server:~$ java -version
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
Maven Home环境变量和版本检查:
damian@damian-server:~$ echo $M2_HOME
/home/damian/Documents/apache-maven-3.3.9
damian@damian-server:~$ mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T13:41:47-03:00)
Maven home: /home/damian/Documents/apache-maven-3.3.9
Java version: 1.8.0_77, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-35-generic", arch: "amd64", family: "unix"
Jenkins config,MAVEN_HOME:/home/damian/Documents/apache-maven-3.3.9 /
如果我在终端中运行Maven工作得很好。
有什么想法吗?
感谢。
答案 0 :(得分:0)
在pom.xml中配置Maven-jar-plugin,以在构建阶段设置项目的主类。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>your.main.Class</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>