Pages

Thursday, March 25, 2010

Installing and configuring Hudson CI

Hudson
Hudson is a very user friendly Continuous Integration Server Software that can be used to monitor any type of project and inform you the status in many different ways. Hudson being an open source software, has an active community and has frequent releases when compared to many other open source projects with added features. It has a huge plug-in base that provides the capability to Hudson CI to be integrated to many other relevant applications.

Installing Hudson

To install Hudson you only need a Servlet/JSP container like Tomcat installed. The Servlet Container needs not to be limited only to Tomcat. But for this tutorial I’m going to use Apache Tomcat.
Tomcat bundle can be downloaded from http://tomcat.apache.org/download-60.cgi


After installing Tomcat you can download Hudson from http://hudson-ci.org/ as a single war file and can be deployed to Tomcat by a single click.

Configuring Hudson for use

Once you go to the Hudson Dashboard all the configurations can be done from ‘Manage Hudson’ link as follows,
figure :1
Once you are inside the ‘Manage Hudson’ link, you can see a screen as follows whether you must go to the ‘Configure System’ link to do the actual configuration.
figure :2
Essential Configuration Settings
Before building any java application we have to do 2 key configurations in ‘Configure System’ link. Those are to provide the JDK path and a build tool path. For this example we are using Ant as the build tool. Both JDK (downloadable from: http://java.sun.com/javase/downloads/widget/jdk6.jsp) and the Ant (downloadable from: http://ant.apache.org/bindownload.cgi) should be installed and tested before doing this step for easy isolation of faults at latter time.
figure :3
Create Users
Hudson doesn’t require users or user groups to be defined before using it to build jobs. But it is always better to define privileges to avoid unnecessary meddling from anonymous users.

To define users first check the ‘Enable Security’ option and select “Hudson’s own user database” and check ‘Allow users to sign up’ option. In the Authorization sub heading, select ‘Matrix base security’ where you can provide privileges to users. I have created ‘Guest’ user for demonstration purposes. Guest was marked with an error symbol because we have not created the Guest user yet, even though we set the privileges to the Guest user. Make sure you give at least one user all the administration privileges which can be used later to setup other configurations. After creating few users, save the settings from the ‘save’ button provided at the end of the page. This will redirect you to a login page.
figure :4
From the login page go to the link named, ‘Create an account’ to create a Guest account as follows,
figure :5
Create a java job
Go to ‘New Job’ tab to create a new job. Then enter a name and select ‘Build a free-style software project’ and click ‘Ok’.
figure :6
Then a job called ‘Test’ is created and the user is directed to job’s configuration page. In here we have to specify the Source Code Management tool path that we are using for this particular project and some additional features like which Build tool to use and the command to archive the artifacts.

As the source code management tool, I’m using Subversion. So I selected ‘Subversion’ under the SCM heading and gave the repository URL to my Test job, which is the repository URL for my project named ‘Welcome’.

Since ‘Welcome’ is a java web application, under the Build heading I selected Invoke Ant because I want Ant to build my java project. After selecting Invoke Ant from the drop down menu, specify the ‘Ant version’ from ‘Default’ to the Ant setup name, you created in the initial system configuration.

In ‘Post-Build Action’ we can program the CI Server to do many other operations other than building the project. Here I have checked ‘Archive the Artifacts’, which will save a working executable file along with the build. For this option it is required to correctly specify which file to be archived.

In ‘Post-Build Action’ it is also possible to set email notifications after every build. This option I have not shown here because I have not configured Email settings in system configuration.
figure :7
Building a .NET project in Hudson
Before creating a job to build a .NET project there is a small system configuration to be done in ‘Configure System’ page. In this page now choose the ‘Manage Plug-ins’ link. After going to that page in the ‘Available’ tag under the heading ‘Build Tools’ check MSBuild option and click ‘Install’ button in the bottom right corner of the same page. After that through internet the plug-in will be downloaded and installed automatically. Once the plug-in is installed, Hudson CI is needed to be restarted.

figure :8
Once the server is restarted, in the ‘Configure System’ page there is a new heading named, ‘MSBuild Builder’. In this, we have to provide the path to MSBuild installation in your machine which is an inbuilt tool shipped with Visual Studio setup and can be usually found in location C:\Windows\Microsoft.NET\framework\version.
figure :9
After performing this we can now create a job to monitor and build a .NET project as same as any java project job as follows,

figure :10
But now in the ‘Build’ heading we have to select ‘Build a Visual Studio project or solution using MSBuild’ option from the drop down instead of ‘Invoke Ant’. For the ‘MSBuild version’ we need to specify the Installation name we provided in the system configuration. And the build file is a file in your .NET project usually having the extension as .sln As the Command Line Arguments you can input the following line or an argument relevant to your project. Other two settings are as the same as for any java job. Now your .NET project job is ready for building. 
figure :11
Integrate Hudson with Jira
For this I used ‘Marvelution’ plug-in which can be used and downloaded for free. The steps in integrating this plug-in clearly explained in its home page http://www.marvelution.com/atlassian/jira-hudson-integration/integration/installation.html

2 comments:

  1. Thanks Sonali for nice article.

    ReplyDelete
  2. Thanks Sonali, now things are clear to me

    ReplyDelete