how to set up jenkins project with glassfish
if you want to use jenkins and glassfish on one instance, it’s very easy to for continious integration.
first you want to add new maven project and configure git repository.
then you need to add pre-build script that pulls changes from repository:
#!/bin/bash
cd /path/to/repository
git pull origin master
then you specify maven goal, e.g.
mvn clean package -DskipTests=true
after that you add post-build script, which deploys build to :
#!/bin/bash
echo -n "Undeploying current version..."
/opt/glassfish4/bin/asadmin undeploy ROOT
echo "done"
echo -n "Stopping glassfish..."
/opt/glassfish4/bin/asadmin stop-domain yourdomain
echo "done"
echo -n "Starting glassfish..."
/opt/glassfish4/bin/asadmin start-domain yourdomain
echo "done"
echo -n "Deploying ROOT.WAR..."
/opt/glassfish4/bin/asadmin --user admin deploy --contextroot / --name ROOT /var/lib/jenkins/workspace/projectname/target/ROOT.war
echo "done"
aslo you want to use –passwordfile option, that allows you not to type password every time you run this script. passwordfile contains AS_ADMIN_PASSWORD=yourpassword
this would probably work without stopping and starting domain.
after setting up project you want to build it, and schedule your build.