2017-05-07 304 views
2

我有一個Maven項目,我想在使用Jenkins的Payara服務器上部署。有兩個項目:一個域項目和一個Spring Web MVC項目。 Spring項目被配置爲在域項目之後構建,因爲它依賴於域項目。Jenkins的Maven構建失敗

每次我提交我的項目時,都會觸發構建。但是,我總是得到以下錯誤:無法解析POM。請參閱下面的完整控制檯輸出。

這是使用似鯖水狼牙魚和詹金斯我的第一次,我真的不能滿腦子都在我做錯了什麼......在正確的方向任何幫助或指導將不勝感激:)

控制檯輸出

Started by GitHub push by WouterCypers 
Building in workspace /root/.jenkins/workspace/bookstore domain 
> git rev-parse --is-inside-work-tree # timeout=10 
Fetching changes from the remote Git repository 
> git config remote.origin.url https://github.com/ucll-ip/project-ip-WouterCypers.git # timeout=10 
Fetching upstream changes from https://github.com/ucll-ip/project-ip-WouterCypers.git 
> git --version # timeout=10 
using GIT_ASKPASS to set credentials 
> git fetch --tags --progress https://github.com/ucll-ip/project-ip-WouterCypers.git +refs/heads/*:refs/remotes/origin/* 
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10 
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10 
Checking out Revision 5dec7ef129e3aa4f142e0ffd41579c741aab86be (refs/remotes/origin/master) 
> git config core.sparsecheckout # timeout=10 
> git checkout -f 5dec7ef129e3aa4f142e0ffd41579c741aab86be 
> git rev-list a3f63a2901948bc6f55e3f2bcdeca5daebc1ea08 # timeout=10 
Parsing POMs 
Established TCP socket on 54633 
[bookstore-domain] $ /usr/lib/jvm/jdk1.8.0_131/bin/java -cp /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven33-agent-1.8.1.jar:/root/.jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/boot/plexus-classworlds-2.5.2.jar:/root/.jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/conf/logging jenkins.maven3.agent.Maven33Main /root/.jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven /opt/payara41/glassfish/domains/domain1/applications/jenkins/WEB-INF/lib/remoting-3.4.1.jar /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven33-interceptor-1.8.1.jar /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.8.1.jar 54633 
<===[JENKINS REMOTING CAPACITY]===>���channel started 
Executing Maven: -B -f /root/.jenkins/workspace/bookstore domain/bookstore-domain/pom.xml clean install -DskipTests 
java.lang.reflect.InvocationTargetException 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238) 
    at jenkins.maven3.agent.Maven33Main.launch(Maven33Main.java:176) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:139) 
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:70) 
    at hudson.remoting.UserRequest.perform(UserRequest.java:153) 
    at hudson.remoting.UserRequest.perform(UserRequest.java:50) 
    at hudson.remoting.Request$2.run(Request.java:336) 
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:748) 
Caused by: java.lang.NoSuchFieldError: DEFAULT_USER_SETTINGS_FILE 
    at org.apache.maven.cli.DefaultMavenExecutionRequestBuilder.settings(DefaultMavenExecutionRequestBuilder.java:658) 
    at org.apache.maven.cli.DefaultMavenExecutionRequestBuilder.getMavenExecutionRequest(DefaultMavenExecutionRequestBuilder.java:149) 
    at org.jvnet.hudson.maven3.launcher.Maven33Launcher.getMavenExecutionRequest(Maven33Launcher.java:150) 
    at org.jvnet.hudson.maven3.launcher.Maven33Launcher.main(Maven33Launcher.java:127) 
    ... 21 more 
channel stopped 
ERROR: Failed to parse POMs 
java.io.IOException: java.lang.reflect.InvocationTargetException 
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:179) 
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:70) 
    at hudson.remoting.UserRequest.perform(UserRequest.java:153) 
    at hudson.remoting.UserRequest.perform(UserRequest.java:50) 
    at hudson.remoting.Request$2.run(Request.java:336) 
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:748) 
    at ......remote call to Channel to Maven [/usr/lib/jvm/jdk1.8.0_131/bin/java, -cp, /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven33-agent-1.8.1.jar:/root/.jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/boot/plexus-classworlds-2.5.2.jar:/root/.jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/conf/logging, jenkins.maven3.agent.Maven33Main, /root/.jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven, /opt/payara41/glassfish/domains/domain1/applications/jenkins/WEB-INF/lib/remoting-3.4.1.jar, /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven33-interceptor-1.8.1.jar, /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.8.1.jar, 54633](Native Method) 
    at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1537) 
    at hudson.remoting.UserResponse.retrieve(UserRequest.java:253) 
    at hudson.remoting.Channel.call(Channel.java:822) 
    at hudson.maven.ProcessCache$MavenProcess.call(ProcessCache.java:161) 
    at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:873) 
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534) 
    at hudson.model.Run.execute(Run.java:1728) 
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:544) 
    at hudson.model.ResourceController.execute(ResourceController.java:98) 
    at hudson.model.Executor.run(Executor.java:404) 
Caused by: java.lang.reflect.InvocationTargetException 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:139) 
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:70) 
    at hudson.remoting.UserRequest.perform(UserRequest.java:153) 
    at hudson.remoting.UserRequest.perform(UserRequest.java:50) 
    at hudson.remoting.Request$2.run(Request.java:336) 
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:748) 
Caused by: java.lang.Exception: java.lang.reflect.InvocationTargetException 
    at jenkins.maven3.agent.Maven33Main.launch(Maven33Main.java:179) 
    ... 14 more 
Caused by: java.lang.reflect.InvocationTargetException 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238) 
    at jenkins.maven3.agent.Maven33Main.launch(Maven33Main.java:176) 
    ... 14 more 
Caused by: java.lang.NoSuchFieldError: DEFAULT_USER_SETTINGS_FILE 
    at org.apache.maven.cli.DefaultMavenExecutionRequestBuilder.settings(DefaultMavenExecutionRequestBuilder.java:658) 
    at org.apache.maven.cli.DefaultMavenExecutionRequestBuilder.getMavenExecutionRequest(DefaultMavenExecutionRequestBuilder.java:149) 
    at org.jvnet.hudson.maven3.launcher.Maven33Launcher.getMavenExecutionRequest(Maven33Launcher.java:150) 
    at org.jvnet.hudson.maven3.launcher.Maven33Launcher.main(Maven33Launcher.java:127) 
    ... 21 more 
Warning: you have no plugins providing access control for builds, so falling back to legacy behavior of permitting any downstream builds to be triggered 
Finished: FAILURE 

pom.xml的Spring項目的

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>org.ucll</groupId> 
    <artifactId>bookstore-springmvc</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>war</packaging> 

    <name>bookstore-springmvc</name> 

    <properties> 
     <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 

     <jstl.version>1.2</jstl.version> 
     <java.version>1.8</java.version> 
     <javaee.version>7.0</javaee.version> 
     <maven.war.version>2.3</maven.war.version> 
     <spring.version>4.3.6.RELEASE</spring.version> 
     <spring.security.version>4.2.2.RELEASE</spring.security.version> 
     <payara.home>/c/Program Files/payara41</payara.home> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>org.ucll</groupId> 
      <artifactId>bookstore-domain</artifactId> 
      <version>1.0-SNAPSHOT</version> 
     </dependency> 
     <!-- FRAMEWORK ETC --> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>jstl</artifactId> 
      <version>${jstl.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>javax</groupId> 
      <artifactId>javaee-web-api</artifactId> 
      <version>${javaee.version}</version> 
      <!-- provided indicates that we do need this dependency for compilation and test, but not at runtime --> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-webmvc</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 

     <!-- SPRING SECURITY --> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-web</artifactId> 
      <version>${spring.security.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-config</artifactId> 
      <version>${spring.security.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-taglibs</artifactId> 
      <version>${spring.security.version}</version>   
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.1</version> 
       <configuration> 
        <source>${java.version}</source> 
        <target>${java.version}</target> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-war-plugin</artifactId> 
       <version>${maven.war.version}</version> 
       <configuration> 
        <failOnMissingWebXml>false</failOnMissingWebXml> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.glassfish.maven.plugin</groupId> 
       <artifactId>maven-glassfish-plugin</artifactId> 
       <version>2.1</version> 
       <configuration> 
        <glassfishDirectory>${payara.home}/glassfish</glassfishDirectory> 
        <user>admin</user> 
        <passwordFile>${payara.home}/glassfish/config/password.txt</passwordFile> 
        <debug>true</debug> 
        <terse>false</terse> 
        <echo>true</echo> 
        <domain> 
         <name>domain1</name> 
         <adminPort>4848</adminPort> 
         <httpPort>8080</httpPort> 
        </domain> 
        <components> 
         <component> 
          <name>${project.artifactId}</name> 
          <artifact>target/${project.build.finalName}.war</artifact> 
         </component> 
        </components> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

</project> 

的pom.xml領域工程

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>org.ucll</groupId> 
    <artifactId>bookstore-domain</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <maven.compiler.source>1.8</maven.compiler.source> 
     <maven.compiler.target>1.8</maven.compiler.target> 

     <java.version>1.8</java.version> 
     <junit.version>4.12</junit.version> 
     <jgiven.version>0.12.1</jgiven.version> 
     <maven.surefire.version>2.19</maven.surefire.version> 
     <persistence.version>2.6.4</persistence.version> 
     <derbyclient.version>10.13.1.1</derbyclient.version> 
     <spring.security.version>4.2.2.RELEASE</spring.security.version> 
     <hibernate.version>5.4.1.Final</hibernate.version> 
     <glassfish.javax.el.version>3.0.1-b08</glassfish.javax.el.version> 
     <spring.context.version>4.3.6.RELEASE</spring.context.version> 
     <jgiven.version>0.12.1</jgiven.version> 
     <maven.surefire.version>2.19</maven.surefire.version>   
    </properties> 

    <dependencies> 

     <!-- TESTING --> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>${junit.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>com.tngtech.jgiven</groupId> 
      <artifactId>jgiven-junit</artifactId> 
      <version>${jgiven.version}</version> 
     </dependency> 

     <!-- JPA --> 
     <dependency> 
      <groupId>org.eclipse.persistence</groupId> 
      <artifactId>org.eclipse.persistence.jpa</artifactId> 
      <version>${persistence.version}</version> 
     </dependency> 

     <!-- DERBY DB --> 
     <dependency> 
      <groupId>org.apache.derby</groupId> 
      <artifactId>derbyclient</artifactId> 
      <version>${derbyclient.version}</version> 
     </dependency>   

     <!-- BEAN VALIDATION --> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-validator</artifactId> 
      <version>${hibernate.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-validator-cdi</artifactId> 
      <version>${hibernate.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.glassfish</groupId> 
      <artifactId>javax.el</artifactId> 
      <version>${glassfish.javax.el.version}</version> 
     </dependency> 

     <!-- SPRING CONTEXT --> 
     <!-- used in Author.java for validation of the Date format --> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context</artifactId> 
      <version>${spring.context.version}</version> 
      <type>jar</type> 
     </dependency> 

    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.1</version> 
       <configuration> 
        <source>${java.version}</source> 
        <target>${java.version}</target> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <configuration> 
        <testFailureIgnore>true</testFailureIgnore> 
       </configuration> 
       <version>${maven.surefire.version}</version> 
      </plugin> 
      <plugin> 
       <groupId>com.tngtech.jgiven</groupId> 
       <artifactId>jgiven-maven-plugin</artifactId> 
       <version>${jgiven.version}</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>report</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <format>html</format> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

</project> 

回答

2

這似乎是與詹金斯,already answered here的問題。

我的解決辦法是設置更改構建配置:

配置>構建>高級

  • 設置Settings fileSettings file in filesystem和進入路徑的設置文件。在我的情況下:/root/.m2/settings.xml
  • 設置Global Settings fileGlobal settings file on filesystem並輸入您的全局設置文件的路徑。我沒有(我認爲),所以我只是將它設置爲/root/.m2/settings.xml也。

這應該做的伎倆。現在我只需要解決其他十幾個編譯錯誤:)