One of the advantages of Hudson over Buildbot, for instance, is that almost everything is done via its web interface. So anyone can manage the continuous integration server easily. Another advantage over the other alternatives is Hudson has many available plugins, so you don’t need to write your own.
Hudson runs on Java, so the next step is to install Java and its dependencies.
You can install all Java related packages this [not recommended] way:
$ [sudo] apt-get install ca-certificates-java daemon default-jre\
> default-jre-headless gcj-4.4-base gcj-4.4-jre-headless gcj-4.4-jre-lib\
> icedtea-6-jre-cacao java-common libaccess-bridge-java\
> libaccess-bridge-java-jni libgcj-common libgcj10 libjline-java \
> openjdk-6-jre openjdk-6-jre-headless openjdk-6-jre-lib\
> rhino tzdata-java tzdata
Or try installing with the information in the next section and if you have problems, run:
$ [sudo] apt-get install -f
The recommended installation from Hudson site for Debian users is installing through the .deb package. The advantages are: you can automatically upgrade hudson via apt and use the service or /etc/init.d resource to start the daemon on boot.
To install Hudson as they recommend, do the following:
Add the key to your system:
$ wget -O /tmp/key http://hudson-ci.org/debian/hudson-ci.org.key
$ [sudo] apt-key add /tmp/key
Then install Hudson:
$ wget -O /tmp/hudson.deb http://hudson-ci.org/latest/debian/hudson.deb
$ [sudo] dpkg --install /tmp/hudson.deb
When you reboot the computer the web daemon will be started at http://localhost:8080. If you don’t want to reboot the computer, run:
$ [sudo] service hudson start
or
$ [sudo] /etc/init.d/hudson start
It is not necessary for all users, but if you want to set up apache to run the web interface, you should follow this tutorial: http://wiki.hudson-ci.org/display/HUDSON/Running+Hudson+behind+Apache
Installing plugins in Hudson is very easy. Just click Manage Hudson, then Manage Plugins. The tab Updates shows all available updates to installed plugins. But what we need now is to install plugins. So we must go to the Available tab and check what we want to be installed and then press the Install button in the end of the page.
The Hudson server hosted at http://ci.cloudsilverlining.org has the following plugins installed for pip project:
Hudson manages “jobs”. Jobs are complete builds to Hudson. For instance, you want to build pip project and run its tests with nosetests. This section assumes you have all needed dependencies installed.
You need to set up some configuration in Hudson before creating your first job. Go to Hudson home page, “Manage Hudson”, then “Configure System”.
In the Mercurial section, fill the “Add Mercurial” section with:
In the Shell section fill the shell executable with /bin/bash.
Then press the “Save” button in the bottom of the page.
Now you were redirected to the job’s configuration page. Here you will tell Hudson how it will build your job. The most important steps are listed (assume Mercurial plugin is installed):
This box will contain all code you want your build run. To run pip’s tests we need to install pip tests’s depencies and run nosetests. Add the following lines to the box (it assumes you have virtualenv in your system’s python):
python -mvirtualenv --no-site-packages pip_virtualenv
source pip_virtualenv/bin/activate
cd $WORKSPACE/..
easy_install -U pip
cd $WORKSPACE
pip install virtualenv scripttest nose
nosetests tests -v
The $WORKSPACE environment variable is the current build workspace, in the case above it is the clone repository path. The cd stuff is a work around to a pip’s bug.
The process execute above means:
Press the “Save” button and in the next page test if the build is correct by clicking “Build now” button.
In the left sidebar will appear the run builds and the running (if exists). Click the top build, then “Console Output”. Now you can watch what Hudson is doing to build your job and watch the results.
If you change anything in your system environment, like updating your environment configuration files, and realize Hudson didn’t catch your changes, try restarting it:
$ [sudo] service hudson stop
$ [sudo] service hudson start
If when you run the start command you get an error telling you the port is being used, wait about 2 or 3 seconds and try the command again - it’s the time the port releasing may take.
What is covered here is the basic knowledge to start setting up and using a Hudson server, the goal is not teaching all about Hudson or all about how to set up every detail.
There is a running Hudson server aimed for pip project here: http://ci.cloudsilverlining.org/view/pip
After starting Hudson on Linux, start your Windows machine and access the Hudson web interface.
Click “Manage Hudson”, “Manage Nodes”, “New Node”. The Node name value must be the Windows machine domain name - mywindowsslave.myhost.com, for instance.
The “Launch method” should be Launch slave agents via JNLP
Then press the Add button, and in the next page click the Launch icon.
Now you are able to create jobs tied to this Windows machine.
The process of creating a job is almost the same as the list in the Creating a Job section, the only difference is that you need to mark the Tie this project to a node option and select what node you want to run that build.
There is a difference in build commands, relying on variables. On Linux they all start with $, like $WORKSPACE. In Windows they will be enclosed by %, like %WORKSPACE%. And everything you were doing depending on Bash, you will need to change to DOS prompt commands and batch files.