Continuous Integration Environment Building

Source: Internet
Author: User
Tags maven central sonatype tortoisesvn

1. Maven3 Installation

1.1 Download Maven

Version: 3.0.3


1.2 Installing MAVEN


[1] Unzip the to the location you want to install, such as D:/maven3.

[2] Setting the MAVEN system environment variable, m2_home=d:/maven3/maven-3.0.3.

[3] Add Maven Bin directory to the System environment variable path,%m2_home%\bin.

[4] Confirm the installation of Maven:

Cmd> mvn-version

Apachemaven 3.0.3 (r1075438; 2011-03-01 01:31:09+0800)


JAVAVERSION:1.6.0_18, Vendor:sun Microsystems Inc.



Osname: "Windows XP", Version: "5.1", Arch: "x86", Family: "Windows"

If error exception in thread "main" java.lang.NoClassDefFoundError, resolve:

Delete the system environment variable in the M2_HOME environment variable path,%m2_home%\bin, and then reset it again OK. This is the maven3.0.3 bug, of course, if you use a variable name other than M2_home will not appear this bug



Eclipse:eclipse 3.7

2.1 Plugin Address

[1] First install the GEF plugin address:

Select version 3.7 To download, the MAVEN plugin will rely on this plugin when installing

[2] Install SVN plugin address:

[3]maven Plugin

M2eclipse-core Update site:

M2eclipse-extras Update Site:

Note: You must have two plug-ins installed, when you click "Run As Server" to run the project when you do not install the extras plugin, you will get an error: "The selected did Notcontain no resources that can run on server m Aven Project "

2.2 Problem occurred during installation

Direct online Installation Maven2 The dependency plugin could not be found and could not be installed. The GEF plugin must be installed before the M2eclipse-core plug-in can be installed, however installing the M2eclipse-extras plugin also relies on the Subclipse plugin. So, the correct installation order for three plugins is:

GEF plugin->subclipse plug-in->m2eclipse plugin

M2eclipse-core plug-in-dependent GEF plug-in

M2eclipse-extras plug-in-dependent subclipse plug-in

When the installation is complete, start eclipse

Note: After installing the M2eclipse plugin, restart eclipse always prompts

Eclipse is running in a JRE, but a JDK is required

The-VM configuration item must be in front of the –vmargs configuration item because a default JVM has been selected for execution to the-vmargs configuration item.

So add this sentence in front of –vmargs:

-VM D:/java/jdk1.6.0_29/bin/javaw.exe





Test everything is OK after startup.

3. Build LAN Mave Server

Nexus is the MAVEN repository manager. If Maven is used in a company, it is often necessary to set up a MAVEN repository server locally and maintain the local repository while acting on the remote repository, to save bandwidth and time, and the nexus can meet this need. In addition, Nexus provides a powerful resource warehouse management function, component search function, which is based on rest, and the friendly UI is a ExtJS rest client that consumes less memory and is based on a simple file system rather than a database. These advantages make it increasingly the most popular MAVEN repository manager.

3.1 Download Nexus

Download the latest version of Nexus,nexus from two versions: open source and professional. Here we download the open source version.

The download interface looks like this:

3.2 Installing the Nexus

There is only one prerequisite for installing a nexus, which is that you must first install Jre,java 5 or Java 6 (Java 6 is recommended).

The Nexus provides two ways to install a bundle bundled with an embedded jetty that can be run directly with the JRE. The second way is the war, which simply publishes it to the Web container and can be used. Here we focus on the first installation method. This way, the Nexus (open source version) can be installed as a separate server. Nexus bindings have a jetty,jetty listening host ( on all configured IP addresses and run by default on port 8081.

Unzip the to any directory, such as D:\nexus, and then configure the environment variable ${nexus_home} to point to the directory D:\nexus\ nexus-oss-webapp-, this is the Nexus installation directory.

The Nexus installation directory always has a sibling directory named "Sonatype-work". This directory contains all the repository and Nexus configuration information, which is configured outside the Nexus installation directory, making the Nexus version update easier. By default, this directory is always used as the sibling directory for the Nexus installation directory to hold resource content and configuration. If you want to change the location of the directory, you can modify the Nexus-work property in the file ${nexus_home}/conf/

3.3 Running Nexus

Go to the following directory location:


In this directory, there are many nexus running platforms to choose from, as shown in:

I am using a Windows system, so select the platform selected in the graph red box: windwos-x86-32. After entering the directory, you can see that there are many batch files. Such as:

If this is the first run, run the Installnexus.bat batch program first, install it as a Windows service, and then run the Startnexus.bat batch program to start the Nexus server. Such as:

When we start the nexus, we are starting a Web server with a default port number of The Nexus runs in a servlet container named Jetty, which is started by a local service wrapper called "Tanuki Java servicewrapper". You can run the Nexus as a Windows service or as a UNIX daemon by configuring this service wrapper.

After launch, the Nexus will be in a running state and listen to all IP addresses ( configured for the current host on port 8081. To use the Nexus, first open a browser and type Url:http://localhost:8081/nexus. (also available with or other configured IP addresses). This will open the Nexus's initial welcome interface as shown in:

Click the "Log In" link in the upper right corner of the page, the login dialog will pop up, the default username is "admin" and the password is "admin123".

As shown in the following:

The post-login interface is as follows:

3.4 Configuring Nexus

After successful login as administrator, you will see a lot of content added to the left navigation bar. Here, we can manage warehouses, configure Nexus Systems, manage tasks, manage users, roles, permissions, view system RSS feeds, manage and view system logs, and more. You can see that the Nexus features are very rich and powerful. In this tutorial, we'll just cover some of the most basic management and operations.

[1] Change Password

In the left column of the admin interface, select "Security" | "Change Password" and the password modification dialog will pop up. It is recommended that you modify the default password to ensure security.

[2] Setting the remote repository index

In Nexus, there are three types of user-managed repositories (except virtual):

Hosted, a local repository, usually we deploy our own artifacts to this type of resource warehouse.

Proxies, proxy resource warehouses, which are used to proxy remote public repositories, such as the MAVEN central repository.

Group, resource warehouse groups, which are used to consolidate multiple hosted/proxy repositories, typically we configure MAVEN to rely on a resource warehouse group.

Nexus Agent three important remote repository:

Maven central repository, Apache snapshot resource pool, and Codehaus snapshot repository.

Each remote repository contains tens of thousands of artifact, all of which are impractical. So the Nexus only maintains their index, uses these indexes to search for artifact, and then downloads the content when needed. However, by default it is forbidden to download these indexes, which is required by configuration to allow the download of indexes. The steps are as follows:

In the left column, select "Views/repositories" | "Repositories", and the right side will open the list of resources managed by the user. Locate the three remote repositories above, and in the Properties window below, set "Download remoteindexes" to "true" and save the changes. As shown in the following:

After the Nexus downloads the remote repository index file, we can search locally for all the components of the remote repository (artifact).

[3] managing the resource pool

In the left column, select "Views/repositories" | "Repositories", and the right side will open the list of resources managed by the user.

In the top column, we can update, add, and delete repositories. Such as:

[4] Managing the MAVEN warehouse Group

The concept of the warehouse group in Nexus is not maven, in Maven's view, whether you are hosted or proxy, or group, for me is the same, I just according to Groupid,artifactid,version and other information to you to the component. To facilitate MAVEN configuration, the nexus can combine multiple warehouses, hosted or proxies into a group so that Maven relies on a group to use all the contents of the warehouse that the group contains.

The Nexus pre-defines the "public repositories" warehouse group, by default merging all predefined release warehouses.

Click "Public repositories" in the list, then select "Configuration" tab below, and in the configuration panel, move the repository in the right "avaiable repositories" to the left "Ordered Grouprepository ",

[5] Configuring MAVEN to use the local Nexus

To use the nexus, we need to configure our MAVEN check Nexus instead of the public repository. To achieve this, we need to edit the mirroring settings in the ~/.m2/settings.xml (Maven 3.0.3 for%maven_home%\conf\settings.xml) file (mirror setting)

The Setting.xml is configured as follows




<name>nexus Public mirror</name>





4. Build SVN server 4.1 install SVN

[1] Software download

Download the Subversion server program.

To the official website of the download binary installation file, come to the binary package download section , find the Windows NT, the 2003, XP and parts, then select Apache2.0 or Apache2.2, so that we can see a lot of downloaded content, can now download setup-subversion-1.5.3.msi .

Download subversion for Windows client TortoiseSVN.

TortoiseSVN is a set of tools for extending Windows shell that can be thought of as a plug-in for Windows Explorer, and Windows can identify the working directory of Subversion after installation.
The official website is TortoiseSVN, download way and similar to the previous SVN server, on the Download page We can choose to download the version, the current highest stable version of the installation file for Tortoisesvn-

[2] Server and client Installation

Server installation, directly run Setup-subversion-1.5.3.msi , according to the prompts to install, so that we have a set of servers to run the environment.

Install TortoiseSVN, also directly run Tortoisesvn- Follow the prompts to install, but the final completion will prompt whether to restart, In fact, restarting just makes the SVN working copy in Windows Special style effective, regardless of all the actual functions, here in order to see the good effect immediately, or restart the machine.

[3] Build repository (Repository)

Running the Subversion server requires first establishing a repository (Repository), which can be viewed as a database of data on the server and can be run directly after the Subversion server is installed, such as:

Svnadmincreate F:\Subversion\SVNdemo\repository

A repository is created under directory E:\svndemo\repository.

We can also use TORTOISESVN to graphically complete this step:
In the directory E:\svndemo\repository "right->tortoisesvn->createrepository here ...", then you can choose the repository mode, where the default is used, and then create a series of directories and files.

[4] Configuring Users and Permissions

Come to E:\svndemo\repository\conf directory, modify svnserve.conf:


#password-db = passwd



password-db= passwd

Then modify the passwd file for the same directory, removing the comments from the following three lines:


#harry = Harryssecret

#sally = Sallyssecret

Finally becomes:


harry= Harryssecret

Ally =sallyssecret

In the passwd file, the character before "=" is the user name, followed by the password. Also note that the comment "#" in front of "[Users]" must be removed.

4.2 Using SVN

[1] running a standalone server

Run in any directory:

Svnserve-d-R F:\Subversion\SVNdemo\repository Our server program has started. Be careful not to close the command-line window, and close the window will also stop Svnserve.

-D is the demon daemon,-R root directory

[2] initializing the import

Come to the root of the project that we want to import, in this case it is E:\svndemo\initproject, and there is a Readme.txt file in the directory:

Right-click->tortoisesvn->import ...
Enter "Svn://localhost/trunk" in URL of repository
Enter your log information in the import message

After the completion of the directory without any changes, if there is no error, the data has been fully imported into the repository we have just defined.

It is important to note that this step can be done entirely on another host with TortoiseSVN installed. For example, the IP of the host running Svnserve is, and the URL part of the input is "Svn://".

[3] Basic client operation

Remove Repository to a working copy:

Come to any empty directory, in this case E:\SVNDEMO\WC1, run right->checkout, enter svn://localhost/trunk in URL of repository, so we get a copy of the work.

Make changes in the working copy and submit:

Open the Readme.txt, make the changes, then right-->commit ... so we can commit the changes to the repository and we'll run it.

Review the changes made:

Readme.txt Right-->tortoisesvn->show Log so we can see all the commits we have for this file. On version 1 Right-->compare with working copy, we can compare the difference between the working copy of the file and version 1.

5.maven Building Eclipse Project 5.1 build Project

Required conditions
Before you start building your project, make sure that your Eclipse + MAVEN environment is installed correctly.

Demo module Structure

Unlike what we might have been accustomed to building a large project, including the Mvc+service+dao model, in order for the project to be service-separated and horizontally extensible, we need to split a large project into several modules to develop. Let's start building the project.

Eclipse New Project Process

After clicking "Finish", the main project is completed.

The main project is built as a pom project, and Web,service,api is built as his module, which is designed for unified management and unified publishing.

Start building each module below

The Web section is currently being created, and the project type needs to be selected as the war.

Repeat the same steps above, and then build Demo-comm, Demo-service, but remember, choose the type "jar"

Once established, the entire project package is as follows

It is important to note that the war project created by Maven does not automatically add Web. XML, requires manual setup of the Web-inf, and manually maintains web. xml

Note: If the Demo-web project relies on Demo-service engineering, manually add dependencies

5.2 Deployment of MAVEN projects

[1]maven Package deployment

Pom.xml add

<!--maven Packaged Deployment -

< distributionmanagement >

< Repository >

< ID >nexus-releases</ID>

< name > Nexus Release Repository</name>

< URL >http://localhost:8081/nexus/content/repositories/releases/</url>

</ Repository >

< snapshotrepository >

< ID >nexus-snapshots</ID>

< name > Nexus Snapshot Repository</name>

< URL >http://localhost:8081/nexus/content/repositories/snapshots/</URL >

</ snapshotrepository >

</ distributionmanagement >

[2]maven configuration file (maven3/config/setting.xml)

Setting.xml add













[3] operating in eclipse

Select Maven Run Configuration

Using the Deploy command from MAVEN

Click Run to complete the deployment

Note: Maven automatically publishes the jar, if at the end of the Sanpshot is automatically published to the snapshot warehouse, the other defaults to

Release Warehouse

6.jenkins Environment Construction

Jenkins, previously known as Hudson, is a continuous integration tool based on Java development for monitoring the repetitive work of order, including:

1. Continuous software release/test project.

2. Monitor the work performed by external calls.

6.1 Installing Jenkins


Official website

[2] Installation Steps

Download the Jenkins.jar to a Linux server and put it under Tomcat WebApp

Start Tomcat

When you are ready to deploy, go to the Jenkins Admin page:

To access http://localhost:8080, the main interface of Jenkins is as follows

6.2 Jenkins Construction Project

Note: We know that Jenkins supports distributed job runs through Master/slave, where the project runs in master, the machine where Jenkins resides.

[1] Creating a job task

Open http://localhost:8080 in IE, click the new Job link, create a new job, and the build job is configured as follows:

Note that Jenkins already has the SVN plugin installed by default.

Click OK

Source Management Choose SVN input SVN URL if a username password is set, a prompt is entered.

If MAVEN is not installed, you will also be prompted to install MAVEN here. Click to install it.

Once configured, go to the following page and click Build Now.

Blue for a successful build, red for failure

Go to the main page of the project and click the Build now link to Build,build to see all build history on this page:

You can then click the link for a build to see a detailed log of a build, as follows:

The project enabled cargo plug-in is automatically deployed to the Web container before it is successfully published, and can be accessed directly

Continuous Integration Environment Building

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: 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.