JENKINS+MAVEN+SVN quickly build a continuous integration environment

Source: Internet
Author: User
Tags svn tomcat

Jenkins is an extensible, continuous integration engine that Jenkins is easy to install and configure, easy to use, and see how we can quickly build a continuous integration environment in minutes.

Suppose we currently have 2 Maven projects: Entities (Java Class Library), Web (Web application, dependency entities). First, install Jenkins

Address http://mirrors.jenkins-ci.org/Download the appropriate Jenkins version.

The Jenkins address for the latest stable version of Windows is: Http://mirrors.jenkins-ci.org/windows-stable/jenkins-1.409.1.zip

Https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+as+a+Windows+service

The Jenkins 1.409.1 version of the decompression, the resulting war package is thrown directly under Tomcat, start Tomcat,jenkins installation is complete, is not very simple AH.

Redhat system Installation process: Https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Red+Hat+distributions Second, Configuring Jenkins

1, open http://10.3.15.78:8080/jenkins/, the first time into the inside no data, we need to create a job, we have 2 projects, we need to create 2 jobs. http://10.3.34.163:9890/jenkins/

2, click on the new job in the upper left corner, the new job page needs to select the type of job, Jenkins supports several types, we choose "Build a MAVEN2/3 project", the job name is: Guan_caijing, as shown in the figure:

3, click the OK button, enter into the detailed configuration interface, detailed configuration of the interface a lot of configuration, but do not fear, most of the use of the default configuration can be, the following say we need to modify several places:

3.1) Source Code Management

Because we use SVN to manage the source code, here we choose Subversion and enter our SVN address in the repository URL:

http://10.3.34.163:9880/guan_caijing/trunk/

After entering the URL address of the SVN library, Jenkins automatically validates the address and gives hints.

Click the Enter credential link in the Red Font section to enter the following page:

After setting up a username and password to access the SVN library, click the OK button to display:

Description the setting was successful. Click the Close button to return to the previous source Code management page. There are no more red warning messages at this time.

3.2) Configure the automatic build plan, assuming that we want the project to be built automatically at 12 and 8 o'clock every day, simply select Build periodically in Build triggers and enter 0 12,20 * * in schedule.

I configured to automatically build every 8 o'clock in the evening

Note: The schedule configuration rule is composed of 5 spaces separated characters, from left to right, respectively: time-of-day month. * On behalf of all, 0 12,20 * * * means "12 and 20:0 any day of any year" to build.

3.3) Configure here, someone may find a red error message in the build configuration node, prompting

Jenkins needs to know where your Maven2 is installed.
The system configuration.

As shown in the figure:

This is because Jenkins cannot find the reason for Maven, click on "System Configuration", the MAVEN configuration of system configuration is added to the directory is OK, the following figure:

I set up the installation directory for JRE 6 and Maven 3.

Click the Save button in the lower left corner to save your settings.

3.4) After all the configuration is saved, our 1th job is completed.

3.5) Create a 2nd job with the same configuration as above. Just change the SVN address to: Http://localhost/svn/Web Three, build manually

After the above configuration, go back to the Jenkins home page, you can see just add the 2 jobs, as shown below:

Click on a 1 job after the "Schedule a Build" image manually built, click Finish, will be on the left of the build queue or build Executor Status display the task being built, after the auto-build, refresh the page, you can see the build results, How to build a project fails, click on the build number behind the project (increment from 1) to enter the project's "Console Output" to see why the project failed to build. Of course we can also configure the results of the build failure to be sent to the mailbox.

So far, 1 simple auto-build environments have been set up, very simple. Iv. Automatic Deployment

After reading the above found that the Jenkins configuration is really simple, a few minutes to build an automatic building environment, but the environment was set up to find 1 problems, now it can be automatically built, However, the built-in Web.war are still in the Jenkins directory and are not published in Tomcat and need to be copied manually.

This is a problem, but don't worry, to achieve the purpose of automatic deployment, you need to install 1 Jenkins deployment plug-ins. Select Manage plugins on the System administration menu:

Select "Optional Plugin" to locate the deploy Plugin 1.8 plugin and select it.

Note: The Deploy Plugin 1.8 plugin supports Tomcat 4.x/5.x/6.x/7.x, JBoss 3.x/4.x, Glassfish 2.x/3.x

Click on the "Install" button at the bottom to display:

Wait patiently:

Until deploy plugin is complete, show success:

Select the box to tick and Jenkins will restart automatically:

At this point, on the Installed tab of the plug-in management, you can see that the deployment plug-in has been installed.

Re-enter the Web configure configuration interface, at the bottom of the discovery of more than 1 configuration items, we configured as follows:

Note: The war file uses a relative directory of Jenkinsworkspace, and the default directory for Hudon is:

C:\Documents and Settings\ user name \. Jenkins\

Workspace directory: C:\Documents and Settings\ user name \. Jenkins\ jobs\web\workspace\

The resulting war is in: C:\Documents and Settings\ user name \. Jenkins\ Jobs\web\workspace\web\target\web.war

Save the configuration and rebuild it again, open the Tomcat WebApps directory and discover that Web.war is finally here and done.

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.