sle*_*ske 6 deployment continuous-integration maven
我们正在使用Maven来构建Web应用程序.
现在我们希望我们的CI(连续集成)服务器自动将WAR部署到用作alpha测试服务器的远程Tomcat实例.
我们使用cargo-maven-plugin来做到这一点,它工作正常.
但是,现在我们还想在部署后对远程Tomcat进行冒烟测试,以确保(重新)部署干净利落.
我们有测试(使用HtmlUnit),但是我们在将它们集成到Maven时遇到了麻烦.到目前为止,我们直接开始运货(使用mvn cargo:redeploy
).这很有效 - 然而,我们找不到事后进行烟雾测试的方法.
那么我们如何才能将maven设置为
在maven构建生命周期中似乎没有这个地方.我们需要定义自定义构建生命周期吗?我们能以某种方式绑定到默认的生命周期阶段吗?哪一个?
您必须做的最重要的事情是将您的集成放入一个单独的maven模块中调用它(用于集成测试).将货物插件放入集成阶段:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<wait>false</wait>
<container>
<containerId>tomcat${tomcat.major}x</containerId>
<zipUrlInstaller>
<url>http://archive.apache.org/dist/tomcat/tomcat-${tomcat.major}/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.tar.gz</url>
<downloadDir>${project.build.directory}/cargo/download/</downloadDir>
<extractDir>${installDir}</extractDir>
</zipUrlInstaller>
<output>${project.build.directory}/tomcat${tomcat.major}x.log</output>
<log>${project.build.directory}/cargo.log</log>
</container>
<configuration>
<home>${project.build.directory}/tomcat-${tomcat.version}/container</home>
<properties>
<cargo.logging>high</cargo.logging>
<cargo.servlet.port>9080</cargo.servlet.port>
</properties>
</configuration>
</configuration>
Run Code Online (Sandbox Code Playgroud)
添加执行块:
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
<goal>deploy</goal>
</goals>
<configuration>
<deployer>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>mod-war</artifactId>
<type>war</type>
<pingURL>http://localhost:9080/mod-war</pingURL>
<pingTimeout>30000</pingTimeout>
<properties>
<context>mod-war</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
</execution>
Run Code Online (Sandbox Code Playgroud)
和关机部分:
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
上面的配置描述了一个完整的集成测试周期,下载了一个tomcat解压缩tomcat的分发部署war文件(dependend项目到tomcat),启动web应用程序,最后停止Tomcat.为了您的目的,您需要更改的是您没有启动阶段,因为您已经有一个正在运行的容器.货物文件中描述了如何做到这一点.最后,您必须将集成测试放入集成测试模块的src/test/java文件夹中,并且不要忘记配置maven-surefire-plugin,如下所示:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<printSummary>true</printSummary>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7351 次 |
最近记录: |