Continuous integration with Hudson

Source: Internet
Author: User
Tags version control system

Http://www.cnblogs.com/AlanLee/p/5372283.html

Speaking of Hudson will have to mention Jenkins, at present, with Jenkins should be more than Hudson, after all, Jenkins Update frequency is faster than Hudson, the two are actually kettle black, will play hudson,jenkins also difficult to go, So Jenkins doesn't introduce much for the time being.

Before introducing Hudson to recommend a book, this book is from Xu Xiaobin Teacher's "maven combat", this article will learn from the contents of the book, Little Alan also read this book, this is a very worth buying book, as a program ape can buy down the collection.

Next, let's go into the world of Hudson:

First step: Install Hudson

hudson:http://hudson-ci.org/, you can get a Hudson.war file when the download is complete,

Note: The Hudson must be running on a JRE1.5 or higher version.

The simplest way to start is to run Hudson.war directly on the command line (this way is not shown here, interested children shoes to find me Mistress Niang asked to know how to play).

Hudson.war as the name implies, since it is a war file, it can naturally be deployed in various web containers, such as Tomcat, Glassfish, Jetty, and JBoss.

Take TOMCAT7 as an example, just throw the Hudson.war into the Tomcat deployment directory WebApps, then go to the Bin directory, run Startup.bat,

After the tomcat boot is complete, open the browser to access Http://localhost:8080/hudson to see the Hudson interface.

First run Hudson will go to the following interface, to choose the plug-in you need to install, select the plug-in need to install and then click Install or Finish,

Later visit Hudson will go directly to Hudson's homepage,

Step two: Prepare for the environment required for continuous integration with Hudson

① Preparing the JDK Runtime Environment: JDK Environment I'll teach you how to set up, you can not look at the back, as an ape, I absolutely do not want to see you such apes, mating also have to see the gene good, well, no kidding.

② Prepare the Subversion repository: The version control system needs to be prepared before the Hudson Continuous Integration task is formally created. Common version control tools include CVS, Subversion, Git, mercurial, and more. Is subversion probably the most widely used version control tool in the world today? Anyway, I do not know what people like to use, but I still prefer to use subversion, popular point is SVN. SVN installation I will not much, I mistress degree Niang certainly know, nothing more to find me Mistress talk about life, talk about ideals.

③ prepare the project management framework: Here I will use Maven, personally in the process of work to think that Maven really is very good, useless ape or used ape are suggested to study deeply, MAVEN installation is so simple, don't tell me you won't, won't find me Mistress degree Niang.

Step three: Basic system settings for Hudson

Before you create a Hudson Continuous integration task, you need to do some basic configuration of the Hudson system, including the JDK installation location and the MAVEN installation location, and Hudson will use these configured JDK and MAVEN for continuous integration tasks. You can also use ant or shell to continuously integrate the project, as well as configure the installation location.

Click System Management on the left side of the Hudson home page, then click System Settings on the right side of the screen to go to the System Setup screen.

On the System Settings page, the first thing to configure is the JDK that Hudson will use. Find the corresponding section in the page and click the Add JDK button, Hudson will prompt the user to install. Hudson default prompts to automatically install the JDK, you can see the Install Automatically check box is selected, but not recommended for automatic installation, generally as a developer, the machine has a JDK, there is no need to spend time waiting for Hudson to download the JDK again. Manually enter the location of the native JDK (often the value of the JAVA_HOME environment variable).

You can configure multiple JDK, which is useful when you need a project to support multiple versions of the JDK, not much here.

MAVEN's configuration is similar to the JDK, no more,

Finally, don't forget to click the Save button at the bottom of the page to save the system settings.

Fourth step: Create a Hudson Task

Click New Task on the left side of the page, then select the name and type of the task on the right side of the page. For a typical MAVEN project, the available types are build a Free-style software project and build a Maven2 project. The former not only supports MAVEN projects, but also supports other types of build tools, such as Ant and Shell. Here we choose the first one, which is more controllable, and is easier to check when there are problems with the task.

After entering the task name and selecting the Free-style type, click the OK button to go to the detailed task configuration page.

Fifth step: Basic configuration of the Hudson task

The first is the name and description of the project, followed by an important option discard old Builds. This option configures how to discard the old build. Hudson each time a build task is executed, the corresponding source code, build output, build report and other files can be saved. Obviously, if each build-related file is saved, it will gradually consume disk space. To do this, Hudson provides two ways for users to choose which build task-related files to keep, respectively:

-days to keep builds: if its value is non-empty n, only the build file within n days is reserved.

-max # of builds to keep: If # is not empty, only the most recently built related files are kept for up to #.

, representing a maximum of 10 recent builds,

Sixth step: The source warehouse location of the Hudson task

Next, you need to configure the project's source control system. On the project configuration page, in the Source Code Management Section, select the Subversion radio button, and then enter the Subversion warehouse address of the project in the Repository URL text box. In general, the other options in this section leave the default values (if they are not seen on the interface, the Hudson Subversion plug-in plugin is not installed),

It is important to note that if authentication is required to access the Subversion repository, Hudson will automatically detect and prompt the user for authentication information. Because I use the local area network SVN, so do not need authentication, there is no real picture to show you,

After you click Enter Credential, Hudson will pop up a page that lets us select the authentication method and enter the authentication information. After entering the correct information, Hudson will be able to read the warehouse source code, using the user name and password way to authenticate:

Sixth step: Build trigger configuration for Hudson tasks

The build triggers section configures how the build is triggered. The three available options are:

-build after other project is built: build this project after the other projects have been built.

-build periodically: Periodically build this project.

-poll SCM: Periodically polls the source repository and discovers updates when it builds the project.

We choose the third way, and the most common way to build, since it is polling, you need to configure the frequency of polling, Hudson used the famous UNIX Task Scheduler tool cron used by the configuration method. Everybody find me Mistress degree Niang to understand a bit.

I configured to poll every 15 minutes.

Seventh Step: Build configuration of Hudson Tasks

Next, configure Hudson to build the project using the Run MAVEN command. Click the Add build step lower triangle button in the Build section and select Invoke Maven 3 (if you do not see this, the description does not install Hudson Maven3 Plugin),

This will default to the MAVEN build project we configured in the system configuration, specifying the commands to run,

It is important to note that the daily Continuous integration task, if successful, will generate a snapshot version of the project build. If you maintain a single system, then the continuous integration task should automatically deploy the build to the use of other projects. Click the Save button at the bottom to save the configuration. At this point, you can manually trigger the first integration by clicking Build now on the left side of the page.

In this way, a simple continuous integration task is configured successfully.

Continuous integration with Hudson

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.