Continuous deployment on Glassfish

Okay, how do we deploy to glassfish from maven on jenkins? Let’s try org.glassfish.maven.plugin:maven-glassfish-plugin first.





Unfortunately, maven tries to go to which is returning 503’s today. After some hoops and loops it still doesn’t work, so let’s try a different approach.

pom.xml, revisited

        <!-- Do not wait after the container is started -->




It works, deploys, undeploys, but requires setting app server each time. Plus by going against maven plugin shorthand naming, requires an excruciatingly tedious

m3 -DskipTests clean package org.codehaus.cargo:cargo-maven2-plugin:undeploy \
org.codehaus.cargo:cargo-maven2-plugin:stop \
org.codehaus.cargo:cargo-maven2-plugin:start \

to run.

AAAAAAAAA! I feel I’m doing something wrong here, so… is there another way? Yes! 🙂

Actually, since I am using Glassfish and it includes a first-class CLI tool called asadmin (short from Application Server admin, as Glassfish used to be called Sun Application Server), let’s use it.


$asadmin undeploy dashboard-web-0.1-SNAPSHOT
$asadmin restart-domain domain1
$asadmin deploy $WORKSPACE/application/application-web/target/application-web-0.1-SNAPSHOT.war

Put that as a script somewhere and execute as a post-build step after a successful build in Jenkins et voila, a contiuously deployed dev version.

Author: ags


2 thoughts on “Continuous deployment on Glassfish”

  1. Why is it inportant to undeploy first, and then redeploy?
    Can’t u just deploy and let glassfish take care of it?

  2. Simple answer is: because the app was a bit messy ;(
    When we cleared this up, we started to do redeploy without the restart each time 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.