Home

Hudson's real top page lives in https://hudson.dev.java.net/ and link to three pages in the Wiki

News

Do you blog about Hudson? Do you have any interesting URL to share with Hudson community? Check out our News Aggregator.

Cómo conseguir que Subversion avise a Hudson para lanzar una build
Hudson
Cómo instalar Hudson en Apache Tomcat
Using the Hudson build integration system with Rational Team Concert
A Campfire plugin for Hudson
Our last OSLD resulted in a new hudson plugin: a build notifier for Campfire. Right now it is pretty simple and just posts the last build result in a chat room: You can configure your account data and the room to join in the job config page under Post Build actions: But there is more to [...]
Creating a Continuous Integration Server for Java Projects Using Hudson

In a previous article we demonstrated how to setup a Linux server to use Maven, the primary Java build tool. Now we’ll look at how to use Hudson to provide continuous integration to your build environment. Just what is continuous integration? Think of it this way: you have a team of developers who are all busily committing code to your source code repository. Each developer is focused on his or her role, or area of functionality, for the system being developed. A continuous integration (CI) engine is an automated build system that checks out the most current code from the source code repository, builds it, and makes the resulting artifacts available for download and/or review. It’s also a great way to see if the entire system is, in fact, compilable. More often than we’d like to admit, developers check in their code without checking for compile errors – creating a problem for others in the team who update their local sources to the trunk, only to find the system no longer compiles! The Continuous Integration Engine can be linked to a mailing list to notify developers that the build has failed. Additionally, it can show a “diff” of what has changed since the previous build, so users can see exactly who the culprit is – and follow up with merciless ridicule.

So why use Hudson to create a continuous integration server? There are certainly other CI engines out there, such as the primary open source rivals to Hudson: Apache Continuum and CruiseControl. Some good commercial CI engines are also available, but those are beyond the scope of this article.

We’ve worked with both Continuum and CruiseControl in the past, and consider them to be functional – in an adequate sort of way. Continuum’s web-based front-end isn’t bad, and for the most part it does what it’s designed to do. We’ve found CruiseControl to be more competent than Continuum when it comes to stability, although we must admit that we have not tried any of Continuum’s newer builds. But when it comes to ease of configuration Hudson wins, hands down. If, like us, you’re visually-oriented, and if you find it painful to edit an XML file to configure CI (as is the case with CruiseControl), Hudson’s graphical user interface just makes perfect sense.

Interested readers should be able to find more detailed comparisons of CI engines (like this one) with a quick search, but our conclusion – based on a combination of first-hand experience and other people’s opinions – is that Hudson is the current front-runner among open source CI engines.

Before You Start

You’ll need to be proficient in Maven and Subversion before you continue. The principle here is to have a mock application hosted in a Subversion repository. We’ll then download and configure Hudson to access the Subversion repository, and perform continuous integration builds from there. We’ll assume you already have Maven configured. If not, have a look at the tutorial titled Creating a Maven-Based Development Environment on Linux. You’ll also need to have an accessible Subversion server set up somewhere. If you don’t, a good place to get started is at http://subversion.tigris.org/faq.html#repository.

Meat & Potatoes

Creating a Test Project

Let’s start with a software project for illustration purposes. For this, we’ll use Maven to generate a project with one simple command:

mvn archetype:generate

You’ll be asked to select an application type to generate. Let’s go with a simple web application. Choose option 18. Then enter the following information into the prompts:

Define value for groupId: : com.example
Define value for artifactId: : testWebApp
Define value for version: 1.0-SNAPSHOT: : [Press Enter]
Define value for package: com.example: : [Press Enter]
Define value for package: com.example: :
Confirm properties configuration:
groupId: com.example
artifactId: testWebApp
version: 1.0-SNAPSHOT
package: com.example Y: : [Press Enter]

Good job. You now have a fully functional web application that does very, very little indeed. You can compile and execute it for test purposes like this:

cd testWebApp/
mvn -Djetty.port=9999 org.mortbay.jetty:maven-jetty-plugin:6.1.18:run

The reason we use port 9999 is because we have other web applications already running on our machine. Point your favorite web browser to http://localhost:9999/testWebApp and you’ll be greeted by the now famous “Hello World!” greeting. Excited yet?

Importing the Test Project into Subversion

Next we need to import our new project into Subversion. We don’t want to import any generated artifacts so we first perform an mvn clean operation.

mvn clean
cd ..
su
# svnadmin create /var/lib/svn/repositories/testWebApp
# cd ..
# svn import testWebApp file:///var/lib/svn/repositories/testWebApp -m "initial import"

Now remove your existing webapp directory, and check it out from Subversion.

rm -rf testWebApp
svn checkout svn://armor.osdcorp.com/testWebApp

Your Subversion repository will obviously be different. Substitute the svn://armor.osdcorp.com part with your configuration.

In a normal team development environment, your team would now joyfully check out the source from Subversion, make changes, and check them back in. Let’s shift our focus to the role of Hudson, our continuous integration engine of choice.

Downloading and Installing Hudson

To download Hudson:

wget http://hudson-ci.org/latest/hudson.war

Simple as that. Now, to execute it you have two options. You can either drop it into a Servlet container like Tomcat, or you can simply start it up like this:

java -jar hudson.war --httpPort=8075

Again, due to our system already running certain web applications, we can specify an alternate port. Point your browser to http://localhost:8075 and you should be rewarded with the following:

hudson1

We’ll need to do some basic configuration first. Essentially, we need to tell Hudson where the JDK and Maven reside. Click on “Manage Hudson”, then “Configure System”. In the resulting screen, configure the locations respectively. This is what it looks like on our server:

hudson3

Next, make sure you have configured the “Hudson URL” at the bottom of this configuration screen. You need to change it from “localhost” to the actual hostname of your server. Something like this:

hudson4

Excellent. Now click “Save”, and then click on the “New Job” link in top left corner of the page and fill out the resulting form as we have below:

hudson2

Continuing from here, a more detailed page of your project is available:

hudson5

Continued…

hudson6

Some explanation is required here. Hudson has various methods of deciding when to perform a build. These are called build triggers. The method we have chosen here is to poll Subversion every minute. If anything has changed, we perform a build. Other trigger mechanisms exist internally to Hudson. We say internally because there is one other important method to trigger a build. An HTTP GET on http://localhost:8075/job/testWebApp/build will trigger a build from an external source. How is that useful? You could use the Wget utility to trigger that URL from the command line or a shell. It’s particularly handy if you use the Wget command on the URL from within a Subversion post-commit hook. So: every time someone commits a change to your source code repository, a build will be performed automatically. In this way we eliminate the wasteful polling of the Subversion repository by Hudson itself.

Let’s go ahead and set up the post-commit hook now. But first, go back into the testWebapp Hudson job configuration and uncheck the “Poll SCM” checkbox. Then click “Save”. Now we’re ready to configure the post commit hook. Our repository resides in /var/lib/svn/repositories/testWebApp (see above):

cd /var/lib/svn/repositories/testWebApp/hooks
cp post-commit.tmpl post-commit
chmod 755 post-commit

Now edit post-commit and ensure that the last three lines look like this:

REPOS="$1"
REV="$2" wget http://localhost:8075/job/testWebApp/build

That’s it! From now on, every time someone commits code, the build is triggered.

Finishing Up

There’s a lot more you can do with Hudson. It supports multiple other source code control repositories, build triggers, build notifiers… even Twitter and IRC interfaces! It uses plugins to perform much of this functionality. Take a look here for the current list of plugins available. We hope this has been a useful introduction to Hudson. If you’re keen for more, there’s detailed information at the Hudson Website.

slave-status

Releases

What's new in this Wiki?

http://www.bestessays.com

Recently Updated
by Christophe Furmaniak (2 hours ago)
Piwik Analytics Plugin (hudson)
by Michael Rooney (13 hours ago)
Authenticating scripted clients (hudson)
by Jesse Glick (19 hours ago)
Build Secret Plugin (hudson)
by Dan Morrow (20 hours ago)
Re: FindBugs Plugin (hudson)
by Kohsuke Kawaguchi (22 hours ago)
Commercial Support v. 14 (hudson)
by Bertrand Gressier (06 Nov)
Re: M2 Release Plugin (hudson)
by Bertrand Gressier (06 Nov)
Re: M2 Release Plugin (hudson)
by Stefan Bäumler (06 Nov)
Administering Hudson (hudson)
by Emeric Vernat (06 Nov)
Monitoring (hudson)
by Francois Cottet (06 Nov)
Re: The Continuous Integration Game plugin ()
by Kohsuke Kawaguchi (05 Nov)
Script Security Realm (hudson)
by Alan Harder (05 Nov)
Batch Task Plugin (hudson)
by Andrew Bayer (05 Nov)
ClearCase Plugin (hudson)
by Tim Payne (05 Nov)
Dimensions (hudson)
by Michael Robinet (05 Nov)
Naginator Plugin (hudson)

Labels:

Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.
  1. Jan 23, 2008

    Anonymous says:

    When can I expect the Tutorial for Writing javancss Hudson Plug-In to be continu...

    When can I expect the Tutorial for Writing javancss Hudson Plug-In to be continued?

  2. Aug 27, 2008

    manjit says:

    I have an issue with hudson when it tries to checkout source files for a project...

    I have an issue with hudson when it tries to checkout source files for a project from CVS. Let's say I've a project abc under xyz main directory. I need to check out abc directly, not as xyz/abc, using a tag TAG_1 in CVS. I am not able to do so. Is there any additional configurations we can do to achieve the same? One work around I've found is to have the files checked out using other third-party CVS tools and have hudson use these files for a build. But I guess, hudson should be able to manage all these by itself.

    Suggestions are warmly welcome.

    Thanks

  3. Feb 26, 2009

    Harish M says:

    How easy to invoke other tools like IPSl from Hudson? If not, is it easy from Hu...

    How easy to invoke other tools like IPSl from Hudson? If not, is it easy from Hudson to communicate with some port say X of some server? Data flow will be in the XML format or SPML?

     Any information regarding this would be appreciated.

    Thanks

  4. Mar 11, 2009

    thao pham says:

    Is there any way to get the compiler error[s] written into the hudson build fail...

    Is there any way to get the compiler error[s] written into the hudson build failure email? i.e. can we have the console output include in the notify failure email?

  5. Jun 01

    Carolyn Teo says:

    Hi Hudson Users and Experts, I have this issue that I have not been able to sol...

    Hi Hudson Users and Experts,

    I have this issue that I have not been able to solve for some time.

    I have 2 jobs:

    - Both are normal Ant Jobs that pulls out of Subversion

    The issue here is:

    One of the jobs has a Customized Jumpstart in the repository and the Hudson Build will also build this jumpstart.

    However, everytime this Job builds, any subsequent builds that uses Jumpstart will start pointing to the customized Jumpstart in that particular build. This causes all other builds to fail because of the specific customized Jumpstart settings.

    Things Tried:

    - Setting Environment Variable JUMPSTART_HOME to point to Generic Jumpstart in Hudson (The Job using the customized Jumpstart will fail to build)

    - Pass in JUMPSTART_HOME as a variable to the jobs for the build. (Does not work)

    - Getting the build.xml to pick up the JUMPSTART_HOME variable from the system (Did not work unless Hudson Env Variable is set) 

    Seeking your Advice since there's not much documentation on this Item:  

    • Is there an issue with the build or is this a Hudson feature?
    • How do I keep the environment settings in each of these build separate even on the same Hudson Build Engine?

    Thanks!

  6. Jul 05

    Venugopal Shenoy says:

    When is the planned release of NCover PlugIn ? Also there are several issues, r...

    When is the planned release of NCover PlugIn ?

    Also there are several issues, related to JMeter graphs

       like the Min & Max is swapped

       Also the number of errors are not plotted, when the job is shown as failed.


  7. Sep 03

    Rohit Bhagat says:

    I am in phase of implementing hudson for the build automation. I am using some s...

    I am in phase of implementing hudson for the build automation. I am using some shell scripts to perform one of the build step. Cancel build operation (in the middle of build process) leads to the build in illogical state. Is it possible to restrict users to use cancel build operation?

  8. Sep 27

    Hteswar kumar says:

    Hi Team, I am looking for command which can give us information about curr...

    Hi Team,

    I am looking for command which can give us information about currently running jobs and job id at hudson.

    So that I can use this command in my perl script to get running job .

    I would be great help for me and appreciate if anyone reply .

    few inbuild commands are below but not to get running job and job id,

    C:\>java -jar hudson-cli.jar -s http://jptomsw112:8080/hudson/ help
      groovy
        Executes the specified Groovy script
      disable-job
        Disables a job
      delete-job
        Deletes a job
      copy-job
        Copies a job
      enable-job
        Enables a previously disabled job
      version
        Shows the Hudson version
      create-job
        Creates a new job by reading stdin as a configuration XML file
      help
        Lists all the available commands
      clear-queue
        Clears the job queue
      groovysh
        Runs an interactive groovy shell
      restart 
    Thanks,

  9. Oct 07

    Eduard Martinescu says:

    Looks like there is a problem with the Document links on the left hand nav, here...

    Looks like there is a problem with the Document links on the left hand nav, here on the wiki.  At least for me, they all link to the JA version of the documents.

  10. Oct 10

    Jason Carter says:

    Where do you submit bug reports? I found a few bugs within the different plugins...

    Where do you submit bug reports? I found a few bugs within the different plugins...

    1. Oct 10

      Kohsuke Kawaguchi says:

      From the issue tracker link on the left navigation bar.

      From the issue tracker link on the left navigation bar.

  11. Oct 26

    Saniya Chopra says:

    M using Linux master and Windows slave. I used JNLP to launch the slave on ...

    M using Linux master and Windows slave. I used JNLP to launch the slave on Windows. When I used the services.msc command this opened services window and from there I tried to start HudsonSlave service and there it gave the following error

             Could not start the HudsonSlave service on Local Computer

             Error1053: The service did not respond to the start or control request in a timely fashion.

    Plz help me solve this error

  12. Nov 02

    LR says:

    I want to specify a location for the repository files that get checkout off subv...

    I want to specify a location for the repository files that get checkout off subversion outside of "jobs" folder, so all jobs see and use the same location. Is this possible ?