Continuous Integration Using Hudson
Hudson Intro & Terminology
I am sure most of people would have written at least one cron job, if not please write one ;-) Hudson uses the same scheduling logic, except for polling the SCM for changes.
Like a cron job, hudson also start and stops a job at a specified interval or at every SCM commit. Every job has one or more subtask (ant task in our case). Hudson itself doesn't solve the problem of integration. It shortens the time to find a bug by doing a full or incremental build accordingly. It will also alerts the person who committed the last change set, send a mail to mailing list, irc alert.
We will be using following terminology when we discuss more about hudson. the following bullet points is a cut-copy-paste from Hudson Terminology.
- Upstream project: A project can have one or several upstream projects, which means that current project is scheduled depending if the upstream project is built successfully or not. If the upstream project is successful, then the current project is added to the build queue. If the upstream project is broken, then the current project will not be added to the build queue.
- Downstream project: A project can have one or several downstream projects. The downstream projects are added to the build queue if the current project is built successfully. It is possible to setup that it should add the downstream project to the call queue even if the current project is unstable (default is off).
- Stable build: A build is stable when it was built successfully and no publisher is reporting it as unstable.
- Unstable build: A build is unstable when it was built successfully and one or several publishers has reported it as unstable. For example if the JUnit publisher is configured and a test fails then the build will go from stable to unstable.
- Successful build: A build is successful when the compilation reported no errors.
- Broken build: A build is broken when it failed during building it.
- Slave: Slaves are computers that are set up to build projects for a master. Hudson runs a separate program called slave agent on slaves. When slaves are registered to a master, a master starts distributing loads to slaves.
Based on the discussion in the mailing list we have come up with following work flow (Discussion about ci and backout faulty changeset).
- Push to main complete blocks of changesets in pi.
- Means push all the changesets since the last push till the last one that works.
- Detect the first changeset not working and reopen the bug which that one is supposed to fix.
- Re-fix that bug with that bug with a new changeset, test it and start from step 1.
- Mailing List:
- openbravo development mailing list
- openbravo in freenode from [ci-update]
- RSS feeds:
- hudson firefox plugin
Setup and Configuration
Installation on Gentoo
- emerge apache mod_jk tomcat-native
- Configure Apache to serve Hudson through Apache in the port 80
Add -D JK to /etc/conf.d/apache2, in the APACHE2_OPTS line.
- Edit /etc/apache2/modules.d/88_mod_jk.conf
Add: JkMount /* ajp13, at the end, before </IfDefine>
- Set environment variables
echo 'PYTHONPATH=/usr/local/lib/python2.5/site-packages' > /etc/env.d/99mercurial
echo 'ANT_OPTS="-Xmx1024M"' > /etc/env.d/99ant
env-update && source /profile
- Get the latest hudson.war to /var/lib/tomcat-6/webapps/ROOT.war
- Edit server.xml to set UTF-8
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8"/>
- Check permission and ownership of hudson home
ls -ld /srv/hudson drwxr-xr-x 2 tomcat tomcat 4096 Apr 11 16:31 /srv/hudson
- Restart apache and tomcat
- Stop tomcat
- backup the existing file and directory
- replace the root.war file with the latest version
- OB-logo, topbar, favicon and css
- Checkout Hudson custom file
- Replace appropriate files in /var/lib/tomcar-6/webapps/ROOT/
- Start tomcat
Environment setup for ERP
- Environment Installation
- ERP Installation
- To trigger junit test it requires a ant-junit package
Creating and Configuration of build/job can be done using Hudson web interface.
- Create new job select any one of the build type
- Build a maven2 project
- Monitor an external job
- Build a free-style software project
- Build multi-configuration project (alpha)
- Copy existing job
- Configure the specification of job
- Source Code Management
- Repository URL
- Build Triggers
- Build periodically (builds are triggered based on the frequency set here)
- Poll SCM (builds are triggered only when a checnset is found)
- This field follows the syntax of cron (with minor differences). Specifically, each line consists of 5 fields separated by TAB or whitespace.
- Build (Add ant target or shell executable which specifies the build process)
- Move/Copy appropriate Openbravo.properties file to the workspace
- specify the ant targets
- Complete/Nightly builds -> ant clean install.source
- Incremental builds -> ant update.database smartbuild
- Post Build Actions
- Email Notification
- IRC Notification
- Save the settings and trigger the build
- Source Code Management
Process tied with Continuous Integration Hudson
Challenges and moving ahead !
- Integrate Mantis