2012-03-16 67 views
4

我们在构建服务器上使用Cargo with Maven来远程部署从我们的构建服务器到内部QA服务器的WAR文件进行测试。在Maven中使用Cargo来远程部署WAR没有HOT部署

我们目前的项目POM见下文,并适用于热部署。

问题是,而不是热部署,我们希望Cargo插件停止Tomcat实例,部署新的WAR,然后启动Tomcat。有没有办法改变POM来管理这种情况?

我们的Maven构建定义为:

mvn clean deploy ... cargo:redeploy 

而在POM货物插件设置:

    <plugin> 
         <groupId>org.codehaus.cargo</groupId> 
         <artifactId>cargo-maven2-plugin</artifactId> 
         <configuration> 
          <container> 
           <containerId>tomcat7x</containerId> 
           <type>remote</type> 
           <systemProperties> 
            <cargo.jvmargs>-XX:MaxPermSize=256M -Xmx1024m</cargo.jvmargs> 
           </systemProperties> 
          </container> 
          <configuration> 
           <type>runtime</type> 
           <properties> 
            <cargo.hostname>qa-server</cargo.hostname> 
            <cargo.servlet.port>8080</cargo.servlet.port> 
            <cargo.tomcat.manager.url>http://qa-server:8080/manager</cargo.tomcat.manager.url> 
            <cargo.remote.username>username</cargo.remote.username> 
            <cargo.remote.password>pass</cargo.remote.password> 
           </properties> 
          </configuration> 
          <deployer> 
           <type>remote</type> 
           <deployables> 
            <deployable> 
             <groupId>com.ourcompany</groupId> 
             <artifactId>myapp-artifactId</artifactId> 
             <type>war</type> 
             <properties> 
              <context>latest</context> 
             </properties> 
            </deployable> 
           </deployables> 
          </deployer> 
         </configuration> 
        </plugin> 
+0

热部署会出现什么问题?你有没有遇到过任何你希望货物停下来并启动'tomcat'的问题? – tokhi 2013-08-05 10:05:51

回答

4

我们有困难的货物。过了一会儿,tomcat卡住了,不会重新启动。 Cargo不允许启动/停止tomcat。

因此,我们最终做的是放弃货物并使用脚本在距离詹金斯机器一段距离处重新启动tomcat。此外,我们共享用于部署战争的集成机器上的文件夹。我们还使用Maven Assembly插件来处理我们的conf文件和文件夹。

0

什么做一个呼叫到cleanTomcat蚂蚁任务的build.xml文件中,并按照以下流程:

​​

关于通过unludo之前的响应,共享服务器之间的文件夹是一个好办法提高部署阶段的速度。

您也可以使用maven-clean-plugin(是mvn clean之一,但有额外的配置)来清除您的java项目之外的目录,即删除您需要在tomcat容器中删除的内容。