Auto Deploy to Geronimo Server (Linux) by Hudson

1. Install Hudson

– Open PuTYY and connect to Server. (If unavailable, click here to download)

– Run 4 below commands:

sudo apt-get install default-jdk
sudo sh -c "echo 'deb /' > /etc/apt/sources.list.d/hudson.list"
sudo apt-get update
sudo apt-get install hudson

– Reboot server: reboot

– Check if Hudson is running: service hudson status

2. Install Plug-in

a) Open URL, e.g.:

b) Install following plugins:


  • SCP plugin
  • Hudson Subversion Plug-in
  • Hudson CVS Plug-in
  • Hudson Maven3 Plugin
  • These plugins are default choices (Hudson BIRT Charts Plugin ; JNA Native Support Plugin ; XPath Provider Plugin)


c) Finish


3. Install Maven

a) In PuTTY, run apt-get install maven to install Maven.

b) This will take a lot of time.

4) Configure System

a) Click Manage Hudson. Then click Configure System.

b) Configure

  • Check JAVA_HOME: printenv JAVA_HOME


If you don’t see the path of this variable, reference tips at the last of this document.

  • Configure JDK


c) Configure Maven 3

  • Check MAVEN_HOME: printenv MAVEN_HOME
  • Configure Maven 3


d) Configure SCP


Tips: You can configure Hudson to deploy your project to different servers by clicking Add button to create more SCP sites.

e) Click Save.

5. Configure in your project

  • In file pom.xml, add these codes below:

  		<id>geronimoDev</id> // Used in “Execute shell”
  			<finalName>TestSystem</finalName> // .war file name

6. Create New Job

a) Click New Job. Enter a job name. Then click OK.

b) Choose Subversion in Source Code Management

c) Fill in the form:

  • Repository URL – The link of the folder containing your project on SVN. It likes this:



  • Click enter credential
  • Choose User name/password
  • Enter your User name and Password.
  • Click OK. Click Close, then Save.


d) Check-out Strategy:


e) In tab Build

  • Click Add build step, select Execute shell
  • In Command, enter:
mvn clean package -P geronimoDev -Dmaven.test.skip=false

(true: skip Unit Test. false: include Unit Test)


f) Check Publish artifacts to SCP Repository in Post-built Actions

  • Choose SCP site to deploy if you have many servers.


  • Click Add.
  • Enter in Source and Destination (Source where the war file stored can check in Workspace/target)


7. Build Job

a) Click Build button


b) Check Console Output. While Hudson is building, you should open Geronimo (choose Web Apps (WAR)).

c) When Hudson builds “SUCCESS”, you refresh Geronimo to see the change: the old project is removed to deploy the new one. After about 30 seconds, this process will finish, you refresh the web again, and the project will appear with your changes updated.



1. Export variable if don’t see the path when check. (PuTTY)

  • nano /etc/profile –> move to the last
  • export MAVEN_HOME=’/usr/share/maven’
  • Ctrl+X –> Y
  • export MAVEN_HOME=’/usr/share/maven’

(Similar with other variables, maybe for JAVA_HOME, SONAR_RUNNER_HOME)

2. Many job

– In real project, you will have a big workspace, and you will add Sonar and Test Coverage  (JaCoCo) later. When you build project, it will takes a lot of time.

– So, you should create many jobs for difference purposes, such as:

  • Job only for Testing (include Unit Test, not deploy, not Sonar, not JaCoCo)
  • Job only for Deploy (skip Test, not Sonar, not JaCoCo)


– So that you can save a lot of time when you build.

3. War file does not uninstall automatically

– If you deploy by hand (export in eclipse, then install war file in Geronimo), the next time you deploy by Hudson, the war file in system will be replaced by the new one (you can check via WinSCP, the path is “/var/opt/geronimo/deploy”). But on the web interface Geronimo, the old one still remains, so your project won’t be updated.

– You can read log file “geronimo.log” by the path “/var/opt/geronimo/var/log” to see the problem. The main reason is that you deployed war file by hand, so Hudson can’t uninstall the old one automatically on the web Geronimo.

– In this case, you just click uninstall in Geronimo, then click build in Hudson to deploy again. And it goes work correctly so far.

4. Function in to build Hudson

validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy, pre-clean, clean, post-clean.


– Document


  1. System Configurations;
  2. Full job:
  3. Just for Deploy
  4. Just for Test



Kita welcomes your comments...

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s