Hudson configuration manual 1
Chapter 1 What is Hudson? Hudson is a powerful and widely used open source continuous integration server providing development teams with a reliable way to monitor changes in source control and trigger a variety of builds. Hudson excels at integrating with almost every tool you can think of. Use Apache Maven, Apache Ant or Gradle or anything you can start with a command line script for builds and send messages via email, SMS, IRC and Skype for notifications. In addition to providing a platform for continuous integration builds, Hudson can also be extended to support software releases, documentation, monitoring, and a number of use cases secondary to continuous integration. In short, if you can think it, Hudson can do it. From automating system administration tasks with Puppet and verifying infrastructure setup with Cucumber, to building and testing PHP code, to simply building Enterprise Java applications Hudson stands ready to help. Need of continuous integration server Consider a hypothetical group of 20-30 developers working on a large enterprise application. This development team consists of 20-30 developers divided into groups of 5-12 developers working on focused features and components in a larger system. One group focuses on the database and a collection of APIs shared by all other groups, one group focuses on a complex front-end web application, and another group focuses on back-end systems such as billing and inventory which interface with a large Enterprise Service Bus (ESB). In this environment the business drives a number of overlapping development schedules. The web application team tends to work on two week development schedules, and the backend group performs releases in response to changes in the ESB. Any given month resemble a highly choreographed sequence of code freezes, development sprints, and products releases with little room for error and inefficiency. In summary, these 20-30 developers are under constant pressure to deliver, and the technical managers are tasked with Orchestrating the efforts of these various teams to deploy code to production on a regular schedule. This is what the enterprise feels like in 2011: it s very busy, and if you happen to find a bit of free time there is always someone who can create a new requirement. 2
Chapter 2 Installing and Running Hudson 1. Hudson has one prerequisite, a Java Runtime Environment (JRE) compatible with Java 6 or higher. Hudson is most often run with the JRE that is bundled with a Java Development Kit (JDK) installation. Visit the following link to download JRE/JDK http://www.oracle.com/technetwork/java/javase/downloads/index.html 2. The Hudson web site (http://hudson-ci.org/) provides a Java web archive file (WAR) for download. This file can either be started directly or used in an existing Java servlet container or application server. So, first download this WAR file. 3
3. Here is the WAR file downloaded to my PC 4. Next we need to make a source code repository, for this tutorial I will be using GIT as the repository, visit the official website (https://github.com/users) of GIT and make an account over there 4
5. After making an account, click on create a repository 6. Give name to the repository, and set it to public, for private repository GIT will charge you but your rep won t be public 5
7. After creating the repository, GIT will provide you a link of the repository, you will be using this link in Hudson server 8. After that visit this website http://git-scm.com/downloads and download GIT. I will be downloading and installing GIT.exe as I m using Windows 6
9. Now we will be installing GIT and HUDSON plugins on eclipse. For this download ECLIPSE (www.eclipse.org downloads ) and run it. If you are behind a proxy server you need to give the address of proxy server in eclipse, for this go to Window -> and click on Preferences 10. Go to General -> and click on Network Connections, change Active Provide to Native and provide your proxy server address. 7
11. Now go to HELP tab and click on Install New Software. 12. Paste these two links to download and install GIT and Hudson plugin i. Hudson plugin: https://repository.sonatype.org/content/-repositories/forge - sites/m2eclipse-hudson/0.13.0/s/0.13.0.20111015-0033/ ii. Egit plugin: http://download.eclipse.org/egit/updates 8
13. After you have installed both plugins, restart Eclipse. Then go to Window tab -> Show View -> and click on Other 14. Double click on Git Repositories and Hudson Jobs 9
15. You will have Hudson Jobs and Git Repositories at the bottom. 16. Again go to Windows tab and click on Preferences 10
17. Go to Network connections, expand it and click on SSH2. Click on Generate DSA Key to generate Public and Private Key pairs, copy the Public Key. And click on Save Private Key to save the key. 11
18. Go to GIT, click on Account Settings located on top right corner, from there click on SSH Keys present on left side, paste the public key generated in eclipse, give a title to it and click on the Add Key. This Key will provide authentication that valid user is using the repository. You can add multiple keys, if there are multiple users accessing the repository. 19. Up till now we have installed GIT and Hudson plugins on eclipse, have generated and uploaded the key to our GIT source code repository. Now we will create a simple Hello World project on eclipse and will upload it to our repository. 12
20. Go to File -> New -> Java Project 21. Name the project and click on Finish 13
22. Now add a Class to this project 23. Name the class and click on finish 14
24. Finally add HELLO WORLD code, and build the project 25. Now to upload this project, right click on the project, go to Team and click on Share Project 15
26. Select GIT and click next 27. Click on Create repository, name your repository and click Finish 16
28. Click finish 29. Now go to the GIT repository view, right click on Remote and from there click on Create Remote 17
30. Name the remote and click Ok 31. Following window will pop up, click on Change and specify GIT url. 18
32. Specify your GIT path and click Finish 33. And then click save 19
34. Again go to Team, this time you will have wide variety of options, click on Commit 35. Check the JAVA class you want to upload, type in commit message and click Commit 20
36. Go to GIT window, expand origin, and click on Push 37. If your internet is working, eclipse would upload your source code / class to GIT 21
38. Following message, shows source code has been uploaded 39. The following figure shows that hello_world_upload class has been uploaded to my_5th_rep in GIT 22
40. Source code 41. To update the GIT repository some later time with new source code you have to commit again, for this repeat step 34 to 36. 42. Eclipse and GIT are configured and working. Now let s move to Hudson, for this you need to type the following command in command prompt java jar Hudso.war 23
43. Hudson will start loading itself 44. Go to your web browser and type 127.0.0.1:8080, Hudson page will show, this indicates that server is working fine. 24
45. First of all you need to configure Hudson that is to install the necessary plugins and specify path of Java JDK and GIT.exe. For this click on Manage Hudson 46. The following plugins are installed 25
47. After installing plugins go to Configure System and specify the following paths 48. Now let s create a job, click on New Job, specify the job name, choose build a free style software job and click Ok. 26
49. GIT have created the HTTPS and SSH link of the repository copy that 50. Specify the path 27
51. Press the play button, so that job starts building, green icon means build was successful while red icon means there was a failure. 52. Following figure shows build was successful 28
53. Now we will load these jobs from eclipse, for this go to Hudson window, click on the Add Jobs Icon, specify the Build Server url, and, then click on Load Jobs, all the jobs will load, select the jobs you want to watch in eclipse and then press Ok. 54. Now you can build jobs directly from eclipse 29