Set Up Hudson For Continuous Integration Under Linux
Hudson monitors executions of repeated jobs, such as building a software project or jobs run by cron. This article explains how you can set it up on Linux.
1. Create directory structure as follows:
mkdir -p /var /var/hudson /var/hudson/.ssh /var/hudson/bin /var/hudson/workspace /var/hudson/container /var/hudson/ci-tools /var/hudson/java
The purpose of directory layout is to have a standard one and easy to maintain in the future.
2. Create hudson user with the home directory /var/hudson:
useradd -d /var/hudson -c 'Hudson user' hudson
chown -R hudson /var/hudson
3. Download Tomcat 5.5.26 and extract into folder /var/hudson/container/apache-tomcat-5.5.26 (http://www.alliedquotes.com/mirrors/apache/tomcat/tomcat-5/v5.5.26/bin/apache-tomcat-5.5.26.tar.gz):
tar -xzf apache-tomcat-5.5.26.tar.gz
mv apache-tomcat-5.5.26 /var/hudson/container/
4. The path to bin folder of tomcat should be /var/hudson/container/apache-tomcat-5.5.26/bin.
5. Download JRE 5 from and install it into /var/hudson/container/jre1.5.0_15.
6. Download hudson.war from https://hudson.dev.java.net/files/documents/2402/97742/hudson.war (current version is 1.218).
7. Put the hudson.war into webapps folder of tomcat located at /var/hudson/container/tomcat-5.5.26/webapps.
8. Create start-server.sh file at /var/hudson with following content:
sh ./bin/startup.sh &
9. Create stop-server.sh file at /var/hudson with following content:
10. Open the browser at http://localhost:8080/hudson to see the Hudson home page.
11. Copy the slave.jar located under /var/hudson/container/apache-tomcat-5.5.26/webapps/hudson/WEB-INF folder into /var/hudson/bin folder.
1. Download and install following plug-ins: Active Directory.hpi, violations.hpi, emma.hpi, cobertura.hpiTo install plug-in: Go to Hudson Home > Manage Hudson > Manage Plugins, upload the plugin into Hudson by using the Upload control and then restart the Hudson.
2. Configure the email for Hudson using following information:
a. SMTP server : the SMTP server hostname or IP (i.e. prjmail.cybersoft.vn or mail.cybersoft.vn).
b. Default user e-mail suffix : the default suffix for user email such as @cybersoft-vn.com and all user specified without email field will be default to @cybersoft-vn.com i.e. hieult will get firstname.lastname@example.org.
c. System Admin E-mail Address : the email of the administrator of this system (for setting in the From field).
d. Hudson URL : the URL of the Hudson installation for some URL used in the email.
To configure Hudson: Go to Hudson Home > Manage Hudson > Hudson Configuration.
3. Download and install JDK into /var/hudson/java sub-folder.
4. Add the Java setting into Hudson through the Hudson Configuration page.
5. Download and extract Ant into /var/hudson/ci-tools sub-folder.
6. Add the Ant setting into Hudson through the Hudson Configuration page.
7. Download and extract Maven into /var/hudson/ci-tools sub-folder.
8. Add the Maven setting into Hudson through the Hudson Configuration page.
3 Create Project
1. Go to Hudson Home > New Job.
2. Enter name of the job in the Job name textbox, and select Build a free-style software project radio button, and click OK button.
3. Select the JDK use for the project in the JDK combo box.
4. In the Source Code Management section, select the Subversion ratio button, and enter the Subversion URL of the project.
5. Go down with the rest configuration, with following check box on:
- Poll SCM : the Hudson will poll the Source Control Management system for changes and then trigger the build (this may cause to increase the work load of the SCM system).
- Build periodically : setup cronjob for running the build daily such as
- Every minute: * * * * *
- Every 5 minutes: 5 * * * *
- Daily: @daily
- Invoke Ant if the project is Ant or Invoke Maven if the project is Maven.
- Archive the artifacts : Zip the build artifacts and allow access through Hudson Web GUI.
- Publish Javadoc : if you have used javadoc for your project, you can check to publish the javadoc through Hudson Web GUI.
- Publish JUnit test result report : Publish the JUnit report through Hudson Web GUI.
- Record Emma coverage report : Publish the Emma coverage report through Hudson Web GUI.
- Report Violations : publish the code analysis reports such as PMD, CPD, Checkstyle,… through Hudson Web GUI.
- Email notification : Notify the user on build status.
- Publish Cobertura Coverage Report : publish the Cobertura report through Hudson Web GUI.
6. Configure JUnit test report: if you have defined the same directory as specified in the framework the JUnit report should be at **/build/reports/junit/**/*.xml
7. Configure Emma Plug-in: Emma does not accept regex as input so you need to input full path to the emma coverage xml file if you have defined the same directory as specified in the framework the Emma report should be at <<WorkspaceName>>/build/reports/emma/emma.xml
8. Configure Cobertura Plug-in: if you have defined the same directory as specified in the framework the Cobertura report should be at **/build/reports/cobertura/**/*.xml
9. Configure Violations Plug-in: if you have defined the same directory as specified in the framework the reports should be at
a. PMD: **/build/reports/pmd/**/*.xml
b. CPD: **/build/reports/cpd/**/*.xml
c. Findbugs: **/build/reports/findbugs/**/*.xml
d. Checkstyle: **/build/reports/checkstyle/**/*.xml
10. Click Save button to save the configuration.
11. Now the project is ready to be built, click on the Build Now button to build the project.