Question

We're using Cargo with Maven on a build server to remotely deploy a WAR file from our build server to an internal QA server for testing.

Our current POM for the project is seen below, and works properly for a hot deployment.

The problem is that instead of a hot deployment, we would like the Cargo plugin to stop the Tomcat instance, deploy the new WAR, and then start Tomcat. Is there a way to alter the POM to manage this scenario?

Our Maven build is defined as:

mvn clean deploy ... cargo:redeploy

And the cargo plugin settings in the 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>
Was it helpful?

Solution

We had difficulties with Cargo. After a while, tomcat gets stuck and won't restart. Cargo does not permit to start/stop tomcat.

So what we eventually did was giving up cargo and using a script to restart tomcat at a distance from our jenkins machine. Also we share a folder on the integration machine used to deploy our wars. We also use the maven assembly plugin for our conf files and folders.

OTHER TIPS

What about doing a call to a cleanTomcat ant task inside a build.xml file and follow the following flow:

#1. stop, clean container, start
mvn cargo:stop 
    antrun:run <<<<<<< build.xml file to clean +war +warUnpacked +context.xml
    cargo:start

#2. deploy your webapp
mvn cargo:deploy

About the previous response by unludo, sharing a folder between between servers is a good way to increase rapidity for deployment phase.

You can use the maven-clean-plugin (yes the one of mvn clean but with extra configuration) too to clean directories outside your java project i.e. to delete what you need to delete inside your tomcat container.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top