7 Installing and Configuring Hudson for Continuous Integration
This chapter describes how to install and configure Hudson to automate the build process and how to integrate Hudson with Maven.
Topics:
- Prerequisites for Installing and Configuring Hudson
Before you install Hudson, you must meet the prerequistes. - Downloading Hudson
You can download Hudson either as a WAR file or as Linux RPMs. - Installing Hudson
You can install Hudson on Linux or Windows. - Configuring the HTTP Port
If you are using a single host for your artifact repository and continuous integration server, you must change the HTTP port used by Hudson. - Starting Hudson
You can start Hudson and monitor its logs. - Configuring Maven After Startup
After you install Hudson, you must take several steps to configure Maven to work with Hudson. - More Information About Hudson
This document is meant as a quick guide for starting and running Hudson and does not provide extensive detail on Hudson operations.
Prerequisites for Installing and Configuring Hudson
Before you install Hudson, you must meet the prerequistes.
Ensure that you have the following components of the continuous integration system configured before you begin installing Hudson:
-
Subversion server configured and running, as directed in Installing and Configuring Subversion for Version Control.
-
Archiva configured and running as directed in Installing and Configuring the Archiva Maven Repository Manager, which implies that you have an Oracle Fusion Middleware product installed in an Oracle home and have run the Oracle Maven Synchronization plug-in to populate Archiva.
-
JDK 1.6 or higher installed on the Hudson host.
-
Maven 3 installed on the Hudson host.
Downloading Hudson
You can download Hudson either as a WAR file or as Linux RPMs.
The latest production version of Hudson can be downloaded directly from the following location:
Hudson is distributed in two distinct versions:
-
WAR file, which can either run as standalone or can be added to an existing application server installation.
-
Linux RPMs compiled for specific operating systems. Package management support in the form of appropriate repositories are available to install the RPM and necessary dependencies.
This document focuses on Oracle Linux and Windows installation. Details for the other operating systems may vary from these. For instructions on various types of installations, see http://wiki.eclipse.org/Hudson-ci/Installing_Hudson
.
Installing Hudson
You can install Hudson on Linux or Windows.
-
On Linux:
On a Linux computer supporting YUM, run the following commands:
sudo wget -O /etc/yum.repos.d/hudson.repo http://hudson-ci.org/redhat/hudson.repo sudo yum check-update sudo yum install hudson
This installs Hudson as a daemon and creates a Hudson user. This user is used by the server to perform build job-related activities.
-
On Windows:
You must download the Hudson WAR distribution. Then, to install it:
-
Start Hudson in standalone mode by running the following command:
java -jar hudson-3.2.1.war
-
When Hudson starts:
-
Open the following URL in a web browser:
http://localhost:8080
-
Navigate to Manage Hudson, then Install as Windows Service. This enables you to configure Hudson as a standard Windows service.
For instructions, see
http://wiki.eclipse.org/Hudson-ci/Installing_Hudson_Windows_Service
-
-
Configuring the HTTP Port
If you are using a single host for your artifact repository and continuous integration server, you must change the HTTP port used by Hudson.
To change the HTTP port:
-
On Linux
This value is located in the
/etc/sysconfig/hudson
directory withHUDSON_PORT
. -
On Windows
This value is located in the
c:\ciroot\hudson\etc\sysconfig\hudson
directory.
Starting Hudson
You can start Hudson and monitor its logs.
To start Hudson:
-
On Linux
If you have installed Hudson as a service, you can start the application by running the following command:
/etc/init.d/hudson start
You can monitor start up by checking the logs in the following directory:
/var/log/hudson/hudson.log
Run the following command to monitor logs:
tail -f /var/log/hudson/hudson.log
-
On Windows
Start Hudson on Windows as a normal service:
-
Go to Control Panel.
-
Navigate to Administrative Tools, then Services.
-
Select the Hudson service and click Start.
Hudson logs are available in the following location:
HUDSON_HOME/logs
-
Configuring Maven After Startup
After you install Hudson, you must take several steps to configure Maven to work with Hudson.
This section contains the following topics:
Starting Up Hudson for the First Time
The first time you start Hudson, go to the home page to complete the installation:
- Open a browser and go to
http://localhost:8080
(change the port if you modified it during installation). - In the list of plug-ins that is presented, scroll down to find the Subversion, Maven 3 and Maven 3 SNAPSHOT Monitor options and select these options.
- Scroll down to the bottom and click Install.
- Click Finish to move to the Hudson home page.
The rest of the configuration in this section is continued from the Hudson home page and assumes that you are logged in.
Parent topic: Configuring Maven After Startup
Configuring the JDK
You must configure the JDK that you intend to use for direct Java build configurations. To configure:
Parent topic: Configuring Maven After Startup
Specifying the Maven Home
You must specify the Maven 3 location so that Hudson knows where Maven is located. To do so:
Parent topic: Configuring Maven After Startup
Setting Up Maven for Use by Hudson
To utilize Maven settings from Hudson, embed the settings.xml content into a settings object in Hudson's global Maven configuration:
Note:
Oracle recommends that you replace any localhost URL references in the settings.xml with fully qualified domain names or IP addresses because Hudson builds can eventually occur on non-local build hosts.
Parent topic: Configuring Maven After Startup
Installing Hudson Plug-Ins
Hudson jobs may require job-specific customizations of environment variables. Because Hudson does not support this by default, you must install an additional plug-in. To install the plug-in:
- From the Hudson home page, navigate to Manage Hudson, then Manage Plugins.
- Select Available.
- Select Hudson Setenv Plugin.
- Click Install.
- After the installation completes, use the restart option in Hudson to enable the plug-in.
Parent topic: Configuring Maven After Startup
Integrating the Repository
To configure automatic builds when changes are checked in, you must configure Hudson to monitor the artifact repository for SNAPSHOT deployment changes. Such changes trigger builds of affected components that have dependencies on the changed artifacts. To configure Hudson to monitor the artifact repository:
Parent topic: Configuring Maven After Startup
Monitoring Subversion
In addition to monitoring the artifact repository for updated dependencies, the continuous integration server must constantly check the source control system for updates and trigger project builds accordingly. Unlike repository monitoring, software configuration management monitoring must be uniquely configured per build configuration. As you create new build configurations, you must set the Subversion location information for the related project. For more information about setting the location information, see Automating the Build with Hudson.
Subversion support comes with the base Hudson distribution. Other source control systems may require separate Hudson plug-in installation.
Parent topic: Configuring Maven After Startup
More Information About Hudson
This document is meant as a quick guide for starting and running Hudson and does not provide extensive detail on Hudson operations.
You can find the primary source of the official documentation on Hudson in the following location:
http://wiki.eclipse.org/Hudson-ci/Use_Hudson
For new users, you can find introductory guides to Hudson in the following location:
http://wiki.eclipse.org/Hudson-ci/Using_Hudson
The Hudson book is located in the following location: