Yolinux.com Tutorial

Hudson:

Continuous Integration (CI) or periodic build and regression test

This tutorial covers the installation, configuration and use of the Hudson build server on Linux. Hudson is an automated software build and regression test server framework which integrates with your CM system to build and test your software continuously upon every check-in or scheduled for a periodic build and test (e.g. nightly).

The Hudson Continuous Integration (CI) product forked in January 2011. Oracle maintains the Hudson product and the origional developers continued the project with the new open source project name: Jenkins.

This Hudson tutorial is considered depricated and replaced by the Jenkins CI tutorial.

Hudson Tutorial Contents:

Related YoLinux tutorials:

°Cabie Build Server

°Web server configuration

°Subversion and Trac

°Java JUnit tests

°C++ CppUnit tests

°YoLinux Tutorials Index




Free Information Technology Magazines and Document Downloads
TradePub link image


Free Information Technology Software and Development Magazine Subscriptions and Document Downloads


Introduction to Hudson:

Hudson can monitor your CM system to detect a check-in. Upon recognition of this change, Hudson will update a local working directory of code and perform a series of build steps (e.g. "ant clean", "ant compile" or "make clean" and "make"). Unit tests and tests can be performed after each build. Hudson can support multiple CM systems (SVN, CVS, Clearcase, ...) and build frameworks. It can work as a stand-alone server or collectively in a master with multiple reporting nodes configuration to support builds on a variety of OS's and configurations. Hudson supports Ant, Maven or a sequence of shell script based builds, code analysis and unit or integration tests. Hudson has many plug-ins available to extend its feature set and to integrate with other Software tools.

This tutorial will cover the installation, configuration and use of Hudson integrated with an existing Apache server used as a CM web portal.

Other related YoLinux.com Tutorials:

       

Hudson logo


Installation and Configuration:

Download Hudson: Hudson web site

Two example installations:
  1. Basic WAR file and start script
  2. Linux RPM (Red Hat/CentOS) Package

1) Basic Hudson WAR File Configuration:

This example shows the basic Unix/Linux start script used to launch Hudson. All configuration options in this example are set with environment variables and command line arguments:

#!/bin/bash

# Umask set so all in developer group can access and debug Hudson jobs.
# Assign user hudson to be in the developer group.
umask 002

export HUDSON_HOME=/var/hudson
export HUDSON_USER="hudson"
export JAVA_HOME=/usr/java/latest
export CLASSPATH=$JAVA_HOME/lib/tools.jar:./
export ANT_HOME=/opt/apache-ant-1.8.1
export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH
export HUDSON_PORT="8080"
export HUDSON_AJP_PORT="8009"
export HUDSON_DEBUG_LEVEL="5"
export HUDSON_ENABLE_ACCESS_LOG="yes"
export HUDSON_HANDLER_MAX="10"
export HUDSON_HANDLER_IDLE="20"

java -Djava.awt.headless=true -DHUDSON_HOME=$HUDSON_HOME -jar $HUDSON_HOME/hudson.war --accessLoggerClassName=winstone.accesslog.SimpleAccessLogger --simpleAccessLogger.format=combined --simpleAccessLogger.file=$HUDSON_HOME/logs/access_log --prefix=/hudson --daemon
Note --prefix=/hudson is set for the Apache proxy configuration below.

Red Hat Enterprise / CentOS RPM Configuration:

Hudson is available as source, pre-built binaries and as an installable package.

Hudson RPM Installation: rpm -ivh hudson-1.341-1.1.noarch.rpm

wget http://hudson-ci.org/redhat/RPMS/noarch/hudson-1.341-1.1.noarch.rpm
rpm -qilp hudson-1.341-1.1.noarch.rpm
/etc/init.d/hudson
/etc/logrotate.d/hudson
/etc/sysconfig/hudson
/usr/lib/hudson
/usr/lib/hudson/hudson.war
/usr/sbin/rchudson
/var/lib/hudson
/var/log/hudson

Edit the Hudson init script: /etc/init.d/hudson
Add the Java JRE path to line below (line 68):
for candidate in /usr/java/latest/bin/java /usr/lib/jvm/java-1.6.0/bin/java ...

See the YoLinux Java installation tutorial for more information.

Edit settings in /etc/sysconfig/hudson
Define variables used by Hudson init script.
HUDSON_HOME="/opt/BUILDS/Hudson"
HUDSON_JAVA_CMD="/usr/java/latest/bin/java"
HUDSON_USER="hudson"
HUDSON_ENABLE_ACCESS_LOG="yes"
HUDSON_PORT="8080"

...
An RPM installation will generate the user "hudson".
A binary installation of Hudson requires that you create the user:
useradd -d /var/lib/hudson -c 'Hudson user' hudson.
chown -R hudson.hudson /var/lib/hudson
Start Hudson: /etc/init.d/hudson start (or service hudson start)

Note default service configuration: chkconfig --list |grep hudson

hudson          0:off   1:off   2:off   3:on    4:off   5:on    6:off
Hudson can now be access by a web browser: http://hudson.megacorp.com:8080/


Using Apache proxy to access Hudson:

If you don't want users to access the Hudson server directly but would rather that they access via an Apache web server at port 80 and use Apache authentication (e.g. LDAP, NIS, etc), route web traffic through the Apache server and use it as a proxy to access the Hudson server.

  • Note that the Hudson port is specified in the configuration file /etc/sysconfig/hudson
    HUDSON_PORT="8080"
    ...
    
    Defines default Hudson port.

  • Change the prefix Hudson uses so that the default http://servername:8080/ can be accessed as http://servername:8080/hudson

    This is achieved by adding the command line argument --prefix=/hudson to the init script PARMS variable and restart Hudson.

    Edit Hudson init script: /etc/init.d/hudson
    From:
    PARAMS="--logfile=/var/log/hudson/hudson.log --daemon"
    ...
    
    To:
    PARAMS="--logfile=/var/log/hudson/hudson.log --daemon --prefix=/hudson"
    ...
    

    Restart Hudson: /etc/init.d/hudson restart

  • Configure Apache as a proxy to the Hudson server service:

    Allow mod_proxy
    • Ubuntu:
      sudo apt-get install libapache2-mod-proxy-html
      a2enmod proxy
      a2enmod proxy_http
      
    • Red Hat: file /etc/httpd/conf/httpd.conf
      The default below remains as is:
      ...
      LoadModule proxy_module modules/mod_proxy.so
      LoadModule proxy_http_module modules/mod_proxy_http.so
      

      Create file:/etc/httpd/conf.d/hudson.conf
      <IfModule mod_proxy.c>
       ProxyRequests     Off
      
       <Proxy http://localhost:8080/hudson*>
         Order deny,allow
         Allow from all
       </Proxy>
      
       ProxyPass         /hudson  http://localhost:8080/hudson
       ProxyPassReverse  /hudson  http://localhost:8080/hudson
      
      # <Location /hudson/>
      #   AuthType basic
      #   AuthName "Hudson"
      #   AuthUserFile "/srv/passwd/.htpasswd"
      # </Location>
      
      </IfModule>
      

    Restart web server: service httpd restart
    or: apachectl restart

  • Block external access to the Hudson server on port 8080 (only localhost allowed) and only allow network proxy access through Apache on port 80 with the following firewall rules:

    Add to end of /etc/rc.local so it executes upon system boot.

    # Allow loopback access. 
    # Rule for your computer to be able to access itself via the loopback
    # This rule must come before the rules denying port # access!!
    iptables -A INPUT -i lo -p all -j ACCEPT
    iptables -A OUTPUT -o lo -p all -j ACCEPT
    iptables -A INPUT -p tcp -s 0/0 -d 0/0 --dport 8080 -j DROP
    

    SELinux: setsebool -P httpd_can_network_connect true

  • Hudson can now be accessed with a web browser: http://hudson.yourdomain.com/hudson/


Ant Build script: (example)

Hudson can execute scripts, use Apache Ant or Maven build tools. In this example I am using Ant to launch a make file. Typical Java programmers will not need this example and will typically have projects which build with Ant or Maven. Projects based on Makefile builds (typical for C, C++, FORTRAN, etc) may want to use Apache Ant to call makefile targets as shown in this example.

Installation: (choose one option)
  • Install binary tar ball:
    cd /opt
    wget http://mirrors.kahuki.com/apache/ant/binaries/apache-ant-1.8.0RC1-bin.tar.gz
    tar xzf apache-ant-1.8.0RC1-bin.tar.gz
  • Use Red Hat Enterprise 5 YUM (Apache Ant 1.6): yum install ant
Create Ant build script to launch make file targets:
File: build.xml
<project name="projectX" default="hudson" basedir=".">
    <description>
        Hudson Ant file for projectX
    </description>
  <!-- set global properties for this build -->
  <property name="app" location="projectx"/>
  <property name="make.cmd" value="/usr/bin/make"/>
  <property name="build.native" value="./"/>

  <target name="init">
    <!-- Create the time stamp -->
    <tstamp/>
  </target>

  <target name="compile"
        description="compile the source" >
    <exec dir="${build.native}" executable="${make.cmd}" failonerror="true">
    </exec>
  </target>

  <target name="clean"
        description="clean up" >
    <exec dir="${build.native}" executable="${make.cmd}" failonerror="true">
    <arg value="clean"/>
    </exec>
  </target>

</project>

Links:


MS/Visual C++:

DOS commands to clean and build:
  • devenv.exe projectX.sln /clean debug
  • devenv.exe projectX.sln /build debug

Example CMD DOS command scripts to clean and build:

Environment variables for use with the MS/Visual Studio compiler can be found in:

  • MS/Visual Studio .NET 2003: C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat
  • MS/Visual Studio 8.0: C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat
Also see the YoLinux DOS / bash command comparison


Wind River Workbench / VxWorks:

Example of a build for embedded RTOS development using Wind River Workbench / VxWorks:

File: build.xml
<project name="Embedded VxWorks Build for ProjectE" default="hudson" basedir=".">
    <description>
        Hudson Ant file for Embedded VxWorks Build for ProjectE
    </description>
  <!-- set global properties for this build -->
  <property name="make.cmd" value="/opt/WindRiver/utilities-1.0/x86-linux2/bin/make"/>
  <property name="genmake.cmd" value="/opt/WindRiver/workbench-3.1/x86-linux2/bin/wrws_update.sh"/>
  <property name="build.native" value="./"/>
  <property environment="env"/>

  <target name="init">
    <!-- Create the time stamp -->
    <tstamp/>
  </target>

  <target name="genmake" description="Generate Makefile from .project file" >
    <exec dir="${build.native}" executable="${genmake.cmd}" failonerror="true">
    <arg line="-data /home/builds/jobs/ProjectE/workspace -l ProjectE -m"/>
    <env key="WIND_HOME" value="/opt/WindRiver"/>
    <env key="WIND_BASE" value="/opt/WindRiver/vxworks-6.7"/>
    <env key="PATH" value="/opt/WindRiver/diab/5.7.0.0/LINUX386/bin:${env.PATH}"/>
    <env key="LD_LIBRARY_PATH" value="/opt/WindRiver/vxworks-6.7/host/x86-linux2/lib:${env.LD_LIBRARY_PATH}"/>
    <env key="WIND_PLATFORM" value="vxworks-6.7"/>
    <env key="LM_LICENSE_FILE" value="/opt/WindRiver/license/zwrsLicense.lic"/>
    </exec>
  </target>

  <target name="compile" depends="genmake" description="compile the source" >
    <exec dir="${build.native}" executable="${make.cmd}" failonerror="true">
    <arg line="-f PPC604diab/Makefile clean main_all"/>
    <env key="WIND_HOME" value="/opt/WindRiver"/>
    <env key="WIND_BASE" value="/opt/WindRiver/vxworks-6.7"/>
    <env key="PATH" value="/opt/WindRiver/diab/5.7.0.0/LINUX386/bin:${env.PATH}"/>
    <env key="LD_LIBRARY_PATH" value="/opt/WindRiver/vxworks-6.7/host/x86-linux2/lib:${env.LD_LIBRARY_PATH}"/>
    <env key="WIND_PLATFORM" value="vxworks-6.7"/>
    <env key="LM_LICENSE_FILE" value="/opt/WindRiver/license/zwrsLicense.lic"/>
    </exec>
  </target>

</project>
Note that much of this configuration is devoted to setting the environment variables PATH, LD_LIBRARY_PATH and VxWorks environment variables. The VxWork paths should preceed all others so that VxWorks provided tools such as tclsh, used for auto code generation, will be used instead of the Linux tools as they may operate differently due to version and release variations.
This ANT build script first generates the Makefile from the Workbench GUI IDE project file. It then compiles the code using the Makefile.

This configuration is of Apache, Hudson and the Wind River workbench compiler all running on Linux. (Note that the Windriver Workbench/VxWorks installation CDs contain both the Microsoft Windows and Linux installations on the same CD)


Hudson Build Configuration:

From the Hudson web page: http://hudson.megacorp.com/hudson/

  • Select "Manage Hudson" (upper left)
    (URL: http://hudson.megacorp.com/hudson/manage)
    Hudson manage screen shot

  • Select "Configure System":
    • Set Ant configuration:
      Set default ANT and JDK Hudson configuration
      (URL: http://hudson.megacorp.com/hudson/configure)
      Specify ANT_HOME path. When configuring a Hudson project, you must not take the Ant (default) but must specify this version of Ant. Common Pitfall!
      Can get error:
      FATAL: command execution failed.Maybe you need to configure the job to choose one of your Ant installations?
      java.io.IOException: Cannot run program "ant"
    • Set "Global Properties" + "Environment variables" - List of key-value pair
      Environment VariableValue
      ANT_HOME/opt/apache-ant-1.8.0RC1
      PATH$ANT_HOME/bin:$PATH
      CLASSPATH/usr/java/latest/lib/tools.jar:./
    • Subversion: Set URL to repository.

  • Select "create new jobs"
    • Enter a job name and type ("Build a free-style software project" + OK
    • Source Code Management:
      Select CM (i.e. Subversion). If Subversion then also enter the repository URL: http//svn.megacorp.com/svn/ProjectX/trunk
      You will be prompted for authentication login/password if required.
      Check "Use update"
    • Build Triggers:
      Select "Poll SCM" and define a schedule:
      Poll CM system (e.g. Subversion) every 6 minutes (10 times an hour) for updates.
      */6  * * * *
            
      This will detect changes checked into the CM system to trigger a new build.

      Chose a time which is greater than the time to update the local working Subversion repository, compile and run any regresion tests. Configure to handle even the longest of JUnit or CppUnit tests.

      Run build at 2:00am every Tuesday-Saturday
      0 2 * * 2-6
            
      This will run like a nightly build cron job.
    • Build:
      Select from the pulldown list "Invoke Ant" and enter list of targets eg: clean and all
    • Unit Tests:
    • Select "E-mail Notification" and enter email address.
      (Make sure you are running an SMTP daemon: service sendmail start)
    • Select "Save"
Test the system by selecting "Build Now" (upper left hand side of page.)


Hudson Artifacts:

Define list of build artifacts:
  • From the Hudson home page select the Job.
  • From the upper left hand side of the page, select the "Configure" link.
  • In the section "Post-build Actions" select the option "Archive the artifacts".
  • Files to archive: name-your-executable-or-lib-here
    (Comma separated list. Can use **/file.ext notation)
  • After the next build, the project page will show the package icon and list the "Last Successful Artifacts" you specified.
    Hudson package icon


Hudson Plug-ins:

Hudson plug-ins are a way of extending and enhancing the capability of Hudson. Many plug-ins provide an interface with other systems to provide improved integration. One of the wonderful features of Hudson is the seamless integration of the plug-in installation: Hudson (start page) + "Manage Hudson" + "Manage Plugins". Now select the "Available" tab. From here you can select the plugin for Hudson to download and install.

See the current list of: Hudson plug-ins

Hudson can download and manage plugins from the web console but the "hpi" plugin files can also be downloaded indepedently and placed in the plugins directory: /var/lib/hudson/plugins/ Note that this directory gets generated by Hudson after first use when it starts up.

I do recommend some as part of any Hudson installation, the Source Lines Of Code (SLOC) plugin "SLOCCount", "Sidebar-Link" and "Green Balls" plugins.

Plugins:
  • Sidebar: Allow one to post links in the "side" bar.
  • SLOCCount: Post results from a run of the program "sloccount".
  • dOxygen: Link to dOxygen generated documentation from Hudson.


Sidebar-Link Plugin::

Allows one to generate a list of extra links for Hudson main page and view tabs. I use this to generate a link back to our CM server home page.

  • Install Sidebar-Link plugin:
    • Hudson (start page) + "Manage Hudson" + "Manage Plugins".
    • Select the "Available" tab.
    • Select plugin "Sidebar" (under the "User Interface" category) for installation.
    • Then select the "Install" button at the bottom of the page.

  • Configure Plug-in:
    • After installing plug-in, go to your hudson home page and select "Manage Hudson" + "Configure System".
    • There will now be a new option category "Additional Sidebar Links".
    • Select the button "Add Link" and specify the following:
      • Link URL:
      • Link Text:
      • Link Icon:
        Note: that an "Icon" specified as /userContent/ProjectX_logo_24x24.gif would reside in the local file system as $HUDSON_HOME/userContent/ProjectX_logo_24x24.gif (according to documentation) but found $HUDSON_HOME/war/images/24x24/ProjectX_logo_24x24.gif works where $HUDSON_HOME is defined in Hudson configuration file /etc/sysconfig/hudson
        Also set: chown hudson.hudson /opt/BUILDS/Hudson/war/images/24x24/ProjectX_logo_24x24.gif
    • Select button "Save".

Hudson Sidebar-Link Plugin


SLOCCount Plugin::

This plugin will run the sloccount program against your code and report results through Hudson.

  • Install "sloccount":
    • wget http://www.dwheeler.com/sloccount/sloccount-2.26.tar.gz
    • tar xzf sloccount-2.26.tar.gz
    • cd sloccount-2.26
    • links sloccount.html
      ("q" to quit) Install info is at the bottom of the page.
    • vim makefile (or use your favorite editor)
      • PREFIX=/opt/sloccount
      • POSTED_DIR=/root/Admin/sloccount
    • make
    • mkdir -p /opt/sloccount/bin
    • make install

    SlocCount home page

    [Potential Pitfall]: Compilation error:
    # make
    gcc -Wall c_count.c -o c_count
    cp -p c_count java_count
    gcc -Wall lexcount1.c -o lexcount1
    flex -Cfe -t pascal_count.l > pascal_count.c
    /bin/sh: flex: command not found
    make: *** [pascal_count.c] Error 127
        
    Solution to missing dependency:
    • Ubuntu/Debian: yum install flex
      or
    • apt-get install flex

  • Install SLOCCount plugin:
    • Hudson (start page) + "Manage Hudson" + "Manage Plugins".
    • Select the "Available" tab.
    • Select plugin "SLOCCount" (under the "Build Reports" category) for installation.
    • Then select the "Install" button at the bottom of the page.

  • Configure Hudson System:
    After installing plug-in ad restarting Hudson, go to your hudson home page and select "Manage Hudson" + "Configure System".
    (http://hudson.megacorp.com/hudson/configure)
    In the section "Global Properties" + "Environment Variables", add to your PATH:
    • name: PATH
    • value: $ANT_HOME/bin:/opt/sloccount/bin:$PATH
    Then select "Save" at bottom of page.

  • Hudson Project Configuration:
    • Select your build job from the hudson home page.
    • Select "Configure" (top left hand side of page)
    • At the bottom of page under "Post-build Actions" select the "Publish SLOCCount analysis results " box.
    • Set SLOCCount reports: **/sloccount.sc
      (this is the default)
    • Select the "Save" button to save this configuration.

  • Configure Build:
    • Shell Script:
      export PATH=$PATH:/opt/sloccount
      sloccount --wide --details src/ProjectX > sloccount.sc
              
    • Ant: Add target "sloccount"
      (add to build.xml)
      File: build.xml
      ...
      ...
        <property name="basedir" value="./"/>
      
        <target name="sloccount"
                description="Source Lines Of Code count" >
          <delete file="${basedir}/sloccount.sc"/>
          <mkdir file="${basedir}/slocdata"/>
          <exec executable="/opt/sloccount/bin/sloccount" 
                dir="${basedir}"
                output="sloccount.sc"
                failonerror="true">
             <arg line="--duplicates --wide --details --addlangall --datadir slocdata ."/>
             <env key="PATH" value="/opt/sloccount/bin:${env.PATH}"/>
          </exec>
        </target>
      
      ...
      ...
      

After the build following this configuration, there will now be a new link on the upper left corner of the page labeled "SLOCCount". Select to show the SLOC report.

Hudson SLOCCount Plugin


dOxygen Plugin::

This plugin will allow you to view doxygen documentation through Hudson. Note that this plugin does not perform the document generation but just allows one to view the results as a link from within Hudson.

  • Install dOxygen plugin:
    • Hudson (start page) + "Manage Hudson" + "Manage Plugins".
    • Select the "Available" tab.
    • Select plugin "Doxygen" (under the "Build Reports" category) for installation.
    • Then select the "Install" button at the bottom of the page.

  • Hudson Project Configuration:
    • Select your build job from the hudson home page dashboard.
    • Select "Configure" (top left hand side of page)
    • At the bottom of page under "Post-build Actions" select the "Publish Doxygen" box.
    • Set Doxygen config file:
      Doxygen path: ProjectX/Doxyfile.cfg
      Note that this is the configuration file used by dOxygen to generate the report.
    • Select the "Save" button to save this configuration.

  • Configure Build:
    Add dOxygen document generation to your build by adding the ant target "doxygen".
    File: build.xml
    ...
    ...
      <property name="build.native" value="./"/>
      <property name="doxygen.cmd" value="/usr/bin/doxygen"/>
    
      <target name="clean" description="clean up" >
        <delete quiet="true">
          <fileset dir="Docs/html" includes="**/*" />
        </delete>
      </target>
    
      <target name="doxygen"
              description="Process documentation" >
        <exec executable="${doxygen.cmd}" 
              dir="${build.native}"
              failonerror="false">
           <arg value="Doxygen.cfg"/>
        </exec>
      </target>
    
    ...
    ...
    

  • Configure dOxygen:
    DOxygen is typically installed on Linux systems during the initial install, with yum, by RPM or apt-get. This is detailed in the YoLinux Systems Administration tutorial.

    The generation of the dOxygen configuration file and settings are detailed in the YoLinux dOxygen and C++ tutorial.

    The Hudson dOxygen plugin uses the dOxygen config file to locate the generated dOxygen documentation.

    [Potential Pitfall]: The dOxygen configuration file uses the directive "OUTPUT_DIRECTORY" to locate the output for the generated documentation. This may not have the correct directory prefix to match the Subversion base directory as viewed from Hudson. Thus it may be necessary to create a new dOxygen configuration file to fool Hudson into looking in the proper directory.

    Example: original dOxygen configuration file may reference the path as follows:
    File: Doxygen.cfg
    ...
    ...
    OUTPUT_DIRECTORY       = Docs
    ...
    ...
            
    In order for Hudson the find the documentation files, generate a new dOxygen configuration will with the correct relative path:
    File: HudsonDoxyfile.cfg
    # File to trick Hudson dOxygen plugin to find HTML reports location
    PROJECT_NAME           = ProjectX
    OUTPUT_DIRECTORY       = ProjectX/Docs
    OUTPUT_LANGUAGE        = English
    GENERATE_HTML          = YES
    HTML_OUTPUT            = html
    
    This file only used to trick Hudson into looking at the correct location and is not a proper dOxygen configuration file for generating documentation.
    Hudson will now look in ProjectX/Docs/html/ for the files.

Hudson Doxygen Plugin


Hudson Security:

Security can be handled by Apache authentication and authorization if proxied through Apache as detailed above or by Hudson itself.

Turning on Hudson security: Hudson (home page/dashboard) +"Manage Hudson" + Configure system"
Options:
  • Hudson's own user database
  • LDAP
  • Delegate to servlet container
  • Unix user/group database (PAM)

Authorization can also be handled by Hudson options from nothing to setting fine grained Global or Project based authorization control.

Definitions:
  • Authentication: user proves that they are indeed who they say they are. Login and password required.
  • Authorization: user is allowed (authorized) to perform certain functions and have specific access. eg. admin, read only, etc.


Notes:
  • The config file /etc/sysconfig/hudson defines the "HUDSON_HOME" directory under which all of the build jobs and configurations are stored.

  • View Build Results: From the Hudson web page http://hudson.megacorp.com/hudson/, select the job and from the build history then select a build.
    Feedback from the build is available from the left hand side link "Console Output".

  • Hudson will perform a code checkout to $HUDSON_HOME/jobs/Hudson_Job_Name/workplace/projectx
    Where HUDSON_HOME is defined in /etc/sysconfig/hudson

  • Hudson build numbers do not necessarily match Subversion version numbers. It may not be possible to synchronize Hudson build numbers if more than one build is generated from the source repository. For example, if Subversion has source control for four executables, then for each check-in and revision increment of Subversion, there may be no build, one build or more triggered in Hudson.

  • Look for errors in /var/log/hudson.log

  • Hudson architecture: Hudson is a servlet written in Java and runs in the Winstone servlet engine.

  • Hudson updates: Hudson will notify you of Hudson software updates and allow you to download a new Hudson WAR file. You will get an update message similar to the one below:
    Hudson update message

  • Hudson file and directory permissions: Updates and other functions may end in Java errors if directory ownership or permissions are not correct. I got an error message during an upgrade which stated that the file /usr/lib/hudson/hudson.war.tmp could not be created. The fix is to make sure that the directory has the proper security settings. I run Hudson under user "hudson". My fix:
    chown hudson.hudson /usr/lib/hudson/

  • Proxy server configuration:
    Choose one option:
    • Add proxy configuration to bash shell environment:
      Edit user "hudson" bash shell configuration file: /var/lib/hudson/.bashrc
      export http_proxy=http://proxy.megacorp.com:80
      ...
              
      Used by Hudson and plugin updates.
    • Add proxy configuration to Hudson configuration:
      • Select "Hudson" (Hudson home) + "Manage Hudson" + "Configure System".
      • Under the section "Global Properties", subsection "Environment Variables":
        name: http_proxy
        value: http://proxy.megacorp.com:80
      Hudson proxy server configuration
    • Edit proxy configuration file:
      • Look for definition of HUDSON_HOME in file /etc/sysconfig/hudson
      • Edit proxy setting is proxy config file: HUDSON_HOME/proxy.xml

  • [Potential Pitfall]: Running Hudson on the same system with another servlet engine such as Tomcat or JBoss. You may find that you get errors and experience TCP/IP port conflicts if you run Hudson on the same platform as another servlet engine. You will most probably experience conflicts on the HTTP or AJP ports. The setting of the HTTP port is detailed above. To turn off the AJP port, set it to "-1" by adding the following command line argument: --ajp13Port=-1 (-1: disable). To specify an AJP port just set it to the port value desired instead of "-1".

    This command line argument can be set in /etc/sysconfig/hudson
    Change from:
    ...
    HUDSON_ARGS=""
            
    To:
    ...
    HUDSON_ARGS="--ajp13Port=-1"
            
    A full list of arguments can be found by issuing te following command:
    java -jar /usr/lib/hudson/hudson.war --help
    Restart Hudson: /etc/init.d/hudson restart
    Verify the command: ps -auxw | grep hudson

    Note that the AJP port is used to connect the Apache web server with the servlet engine. If using AJP and you change the default AJP port, remember to set /etc/httpd/conf.d/proxy_ajp.conf to the new port number.

  • [Potential Pitfall]: Port conflict on port 34377?

    Hudson can work as a cluster of build servers specialized for various platforms. They will communicate using JNL TCP/IP port 34377 (default setting)

    If you are not using this master - slave custer arrangement, turn it off:
    • Select the link "Hudson" + "Configure System"
    • Select the box "Enable security" category "TCP post for JNLP slave agents"
    • Select the radio button "Disable"
    • Select "Save" at the bottom of the page

  • Contiuous Integration requires a build/compile but is best if some sort of test is applied to verify the correctness of the code. Many unit test frameworks are available to support unit tests. See the YoLinux.com list of testing frameworks for C/C++ and Java


Books icon Books:

publisher cover Continuous Integration: Improving Software Quality and Reducing Risk
(Paperback)
by Steve Matyas, Andrew Glover
Addison-Wesley Professional

Amazon.com
publisher cover Better Software Magazine

Free subscription for software professionals who care about quality. Each issue brings you relevant, timely information to help you build better software. Continuing to deliver in-depth articles on testing, tools, defect tracking, metrics, and management.

Free
Subscription
   

    Bookmark and Share


Advertisements




Copyright © 2010 - 2012 by Greg Ippolito