Tuesday, November 16, 2010

Configuring Hudson for Continuous Integration


Hudson is extremely flexible and the entire configuration is done via UI (no XML editing required). It can be adapted to be used with many development languages, and has plug-in based architecture. It can execute ANT scripts, generate tests, do code analysis, record fingerprints of files, send email to build master or people who broke the build, and so on.

  • Hudson has native integrations with the following OSes. See respective sections for how to make Hudson run in the background automatically:


  • Alternatively, if you have a servlet container that supports Servlet 2.4/JSP 2.0, such as Glassfish v2, Tomcat 5 (or any later versions), then you can run them as services, and deploy hudson.war as you would any other war file.



  • After easy installation, only minor configuration is needed before you can building software.


  • On the main Hudson page at http://localhost:8080/Hudson, click the Manage Hudson link. On the page that comes up next, click Configure System.





  • Specify Java JDK and ANT installations here





    • The next important step is SMTP configuration which allows Hudson to email you notifications of important events like failed builds.


     


    The basic system-level configuration is now complete!
    A project can now be configured.A project is configured as a job in Hudson.
    After creating a new job, configuring a job requires configuring some parameters like :
    • Project Name
    • Description
    • Discard old builds
    • This build is parameterized: Configured parameters will be set as environmental variables in the environment of the running build.
    • Enable project-based security
    • Disable build
    • Source code management: The three options available by default are:
      • Subversion
      • CVS
      • None 
    • Poll SCM  parameters
    • Build periodically
    • Add build step: Click this button to add a directive to run a build script. Your directive can be one of the following:
      • Execute shell
      • Execute Windows batch command
      • Invoke Ant 
      • Invoke top-level Maven targets 
    •  Archive the artifacts: When you select this option and specify the file and directory mask (Ant-style masks that can specify include and exclude), the artifacts matching the mask will be added to the Hudson artifact repository when the build is complete, keyed by job and build sequence number. All prior artifacts of successful builds can optionally be discarded to save disk space on your Hudson server.
    • Record fingerprints of files to track usage: Using a similar Ant-style mask when you select this option, you can direct Hudson to maintain a fingerprint of generated artifacts that enables you to more easily track where else in the system these artifacts are being used.
    • Publish javadoc
    • Publish JUnit test result report
    • Aggregate downstream test results
    • Build other projects
    • E-mail notification
    As seen, configuring a project in Hudson is a matter of few minutes. Hence,the benefits by far outweigh the cost of implementing CI.