我如何在Jenkins中使用Maven多模块项目进行构建

时间:2013-08-19 14:36:49

标签: java maven jenkins hudson

我正在尝试使用Maven进行多模块项目的构建,但是出了点问题。见日志:

[INFO] Working directory: /root/.jenkins/jobs/logreport/workspace/logreport/target
[INFO] Executing goals 'deploy'...
[INFO] [INFO] Scanning for projects...
[INFO] [ERROR] The build could not read 1 project -> [Help 1]
[INFO] [ERROR]   
[INFO] [ERROR]   The project br.com.triersistemas.logreport:logreport:1.0.0.1 (/home/dados/trier/jenkins/jobs/logreport/workspace/logreport/target/checkout/logreport/pom.xml) has 3 errors
[INFO] [ERROR]     Child module /home/dados/trier/jenkins/jobs/logreport/workspace/logreport/target/checkout/logreport/../logreport-client of /home/dados/trier/jenkins/jobs/logreport/workspace/logreport/target/checkout/logreport/pom.xml does not exist
[INFO] [ERROR]     Child module /home/dados/trier/jenkins/jobs/logreport/workspace/logreport/target/checkout/logreport/../logreport-common of /home/dados/trier/jenkins/jobs/logreport/workspace/logreport/target/checkout/logreport/pom.xml does not exist
[INFO] [ERROR]     Child module /home/dados/trier/jenkins/jobs/logreport/workspace/logreport/target/checkout/logreport/../logreport-server of /home/dados/trier/jenkins/jobs/logreport/workspace/logreport/target/checkout/logreport/pom.xml does not exist
[INFO] [ERROR] 
[INFO] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[INFO] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
[INFO] [ERROR] 
[INFO] [ERROR] For more information about the errors and possible solutions, please read the following articles:
[INFO] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] logreport ......................................... FAILURE [48.256s]
[INFO] logreport-common .................................. SUCCESS [0.135s]
[INFO] logreport-client .................................. SUCCESS [0.136s]
[INFO] logreport-server .................................. SUCCESS [0.138s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 51.169s
[INFO] Finished at: Fri Aug 16 16:35:26 BRT 2013
[INFO] Final Memory: 13M/166M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving /root/.jenkins/jobs/logreport/workspace/logreport-client/pom.xml to /root/.jenkins/jobs/logreport/modules/br.com.triersistemas.logreport$logreport-client/builds/2013-08-16_16-34-31/archive/br.com.triersistemas.logreport/logreport-client/1.0.0.2-SNAPSHOT/logreport-client-1.0.0.2-SNAPSHOT.pom
[JENKINS] Archiving /root/.jenkins/jobs/logreport/workspace/logreport-server/pom.xml to /root/.jenkins/jobs/logreport/modules/br.com.triersistemas.logreport$logreport-server/builds/2013-08-16_16-34-31/archive/br.com.triersistemas.logreport/logreport-server/1.0.0.2-SNAPSHOT/logreport-server-1.0.0.2-SNAPSHOT.pom
[JENKINS] Archiving /root/.jenkins/jobs/logreport/workspace/logreport/pom.xml to /root/.jenkins/jobs/logreport/modules/br.com.triersistemas.logreport$logreport/builds/2013-08-16_16-34-31/archive/br.com.triersistemas.logreport/logreport/1.0.0.2-SNAPSHOT/logreport-1.0.0.2-SNAPSHOT.pom
[JENKINS] Archiving /root/.jenkins/jobs/logreport/workspace/logreport-common/pom.xml to /root/.jenkins/jobs/logreport/modules/br.com.triersistemas.logreport$logreport-common/builds/2013-08-16_16-34-31/archive/br.com.triersistemas.logreport/logreport-common/1.0.0.2-SNAPSHOT/logreport-common-1.0.0.2-SNAPSHOT.pom
mavenExecutionResult exceptions not empty
message : Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.1:perform (default-cli) on project logreport: Maven execution failed, exit code: '1'
cause : Maven execution failed, exit code: '1'
Stack trace : 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.1:perform (default-cli) on project logreport: Maven execution failed, exit code: '1'
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:79)
    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:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
    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:724)
Caused by: org.apache.maven.plugin.MojoExecutionException: Maven execution failed, exit code: '1'
    at org.apache.maven.plugins.release.PerformReleaseMojo.execute(PerformReleaseMojo.java:158)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 27 more
Caused by: org.apache.maven.shared.release.ReleaseExecutionException: Maven execution failed, exit code: '1'
    at org.apache.maven.shared.release.phase.AbstractRunGoalsPhase.execute(AbstractRunGoalsPhase.java:89)
    at org.apache.maven.shared.release.phase.RunPerformGoalsPhase.runLogic(RunPerformGoalsPhase.java:135)
    at org.apache.maven.shared.release.phase.RunPerformGoalsPhase.execute(RunPerformGoalsPhase.java:46)
    at org.apache.maven.shared.release.DefaultReleaseManager.perform(DefaultReleaseManager.java:429)
    at org.apache.maven.shared.release.DefaultReleaseManager.perform(DefaultReleaseManager.java:381)
    at org.apache.maven.plugins.release.PerformReleaseMojo.execute(PerformReleaseMojo.java:154)
    ... 29 more
Caused by: org.apache.maven.shared.release.exec.MavenExecutorException: Maven execution failed, exit code: '1'
    at org.apache.maven.shared.release.exec.InvokerMavenExecutor.executeGoals(InvokerMavenExecutor.java:394)
    at org.apache.maven.shared.release.exec.AbstractMavenExecutor.executeGoals(AbstractMavenExecutor.java:85)
    at org.apache.maven.shared.release.phase.AbstractRunGoalsPhase.execute(AbstractRunGoalsPhase.java:81)
    ... 34 more
channel stopped
Finished: FAILURE

我的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/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>br.com.triersistemas.logreport</groupId>
    <artifactId>logreport</artifactId>
    <version>1.0.0.2-SNAPSHOT</version>
    <packaging>pom</packaging>

    <modules>
        <module>../logreport-client</module>
        <module>../logreport-common</module>
        <module>../logreport-server</module>
    </modules>

    <properties>
        <encoding>UTF-8</encoding>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <!-- Timestamp format for the maven.build.timestamp property -->
        <!-- You can reference property in pom.xml or filtered resources (must 
            enable third-party plugin if using Maven < 2.1) -->
        <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
        <!-- Caminhos SVN -->
        <svn.basepath>src.triersistemas.com.br/trier/svn/infra</svn.basepath>
        <svn.projectpath>logreport/branches/producaotb/RMI00325</svn.projectpath>
        <svn.tag>svn://${svn.basepath}/logreport/tags</svn.tag>
        <!-- Diversos -->
        <main.basedir>${project.basedir}</main.basedir>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <distributionManagement>
        <repository>
            <id>trier-releases</id>
            <url>http://nexus.triersistemas.com.br:4647/nexus/content/repositories/trier-releases/</url>
        </repository>
        <snapshotRepository>
            <id>trier-snapshots</id>
            <url>http://nexus.triersistemas.com.br:4647/nexus/content/repositories/trier-snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <scm>
        <developerConnection>scm:svn:svn://${svn.basepath}/${svn.projectpath}/${project.artifactId}/</developerConnection>
        <connection>scm:svn:svn://${svn.basepath}/${svn.projectpath}/${project.artifactId}/</connection>
        <url>svn://${svn.basepath}/${svn.projectpath}/${project.artifactId}/</url>
    </scm>    

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <version>1.0-alpha-2</version>
                <goals>
                    <goal>read-project-properties</goal>
                </goals>
                <configuration>
                    <files>
                        <file>
                            ${main.basedir}/manifest.properties
                        </file>
                    </files>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <releaseVersion>${Specification-Version}.${Implementation-Version}</releaseVersion>
                    <developmentVersion>${Specification-Version}.${Implementation-Version}</developmentVersion>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <resume>false</resume>
                      <tagBase>${svn.tag}</tagBase>
                </configuration>
            </plugin>            
        </plugins>
        <finalName>${project.artifactId}-${project.version}</finalName>
    </build>

</project>

PLS:在Windows中执行Eclipse,它可以运行,命令如下:

clean properties:read-project-properties release:prepare release:perform release:clean

我很期待。

1 个答案:

答案 0 :(得分:0)

您是否使用Jenkins查看了所有项目?检查作业的工作区,确保所有项目都有正确的路径。