SVN + Jenkins + Maven automates the building and deployment of Java environments

Source: Internet
Author: User

1. Description of the environment:


System CentOS 7 x64


ip:10.6.0.126



1.1 First Install configuration svn


Centos 7 installs SVN with Yum, version 1.7.14



# yum-y Install Subversion


View version information after installation is complete

# Svnserve--version


Add SVN running User

Groupadd SVN

Useradd-g svn-s/sbin/nologin SVN


Add SVN repository directory and authorize SVN user rights

Mkdir-p/opt/svndata

Chown-r Svn.svn/opt/svndata


Create SVN repository

Svnadmin Create/opt/svndata/jicki


Cd/opt/svndata/jicki/conf

.

├──authz SVN certification File

├──PASSWD SVN user files

└──svnserve.conf SVN configuration file



Start SVN

Svnserve-d-r/opt/svndata/



1.2 Deployment of Jenkins


First install JDK 7 official website Download JDK7 Latest version


RPM-IVH jdk-7u71-linux-x64.rpm


After the installation is complete ... The installation directory is/usr/java/jdk1.7.0_71/


Next, configure the JDK environment.


Vi/etc/profile

Add three rows at the bottom

Export java_home=/usr/java/jdk1.7.0_71/

Export path= $JAVA _home/bin: $JAVA _home/jre/bin: $PATH

Export lasspath=.:/ Usr/java/jdk1.7.0_71/lib:/usr/java/jdk1.7.0_71/jre/lib: $CLASSPATH


Use settings to take effect

Source/etc/profile



The next step is to install Tomcat.

Http://tomcat.apache.org/index.html

Download the latest stable version of Tomcat


Tar zxvf apache-tomcat-7.0.57.tar.gz

MV Apache-tomcat-7.0.57/opt/local/tomcat

Cd/opt/local/tomcat


Vi/etc/profile

Add at the bottom

Export tomcat_home=/opt/local/tomcat/


Make settings effective

Source/etc/profile



Download Jenkins below

Official Address http://jenkins-ci.org/

Http://mirrors.jenkins-ci.org/war/latest/jenkins.war Download the latest version


MV jenkins.war/opt/local/tomcat/webapps/


Start Tomcat

/opt/local/tomcat/bin/startup.sh


http://10.6.0.126:8080/jenkins/


Access to Jenkins




1.3 Deployment of Maven


: http://maven.apache.org/download.cgi


Tar zxvf apache-maven-3.2.5-bin.tar.gz


MV Apache-maven-3.2.5/opt/local/maven


Vi/etc/profile

Add at the bottom


Export Maven_home=/opt/local/maven

Export path= $MAVEN _home/bin: $PATH


Make settings effective

Source/etc/profile


To see if the installation was successful

Mvn-v



1.4 The Java environment to build the deployment automatically


Create a new job

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/99/wKioL1S1y3Ti7VqPAAKFioKmQQ0718.jpg "style=" float: none; "title=" 1.jpg "alt=" Wkiol1s1y3ti7vqpaakfiokmqq0718.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/9C/wKiom1S1yqqBupzmAAIyCOJm1Pg080.jpg "style=" float: none; "title=" 3.jpg "alt=" Wkiom1s1yqqbupzmaaiycojm1pg080.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/99/wKioL1S1y3SDQr2gAAFuvXd1IFQ134.jpg "style=" float: none; "title=" 2.jpg "alt=" Wkiol1s1y3sdqr2gaafuvxd1ifq134.jpg "/>





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


Because Jenkins could not find Maven, click "System Configuration" and add Maven directory to the MAVEN configuration of system configuration OK.



1.5 Creating a Web project with the MAVEN command


Command format: MVN archetype:generate-dgroupid={project-packaging}-dartifactid={project-name}-darchetypeartifactid= Maven-archetype-webapp-dinteractivemode=false



/opt/webapp


MVN Archetype:generate-dgroupid=com.myweb-dartifactid=mywebapp-darchetypeartifactid=maven-archetype-webapp- Dinteractivemode=false



The MyWebApp directory is generated after execution


The directory structure is as follows


.

├──pom.xml

└──src

└──main

├──resources

└──webapp

├──index.jsp

└──web-inf

└──web.xml



Enter the MyWebApp directory

cd/opt/webapp/mywebapp/



Perform the Build

MVN Install


Build completed will generate a target directory


.

├──pom.xml

├──src

│└──main

│├──resources

│└──webapp

│├──index.jsp

│└──web-inf

│└──web.xml

└──target

├──classes

├──maven-archiver

│└──pom.properties

├──mywebapp

│├──index.jsp

│├──meta-inf

│└──web-inf

│├──classes

│└──web.xml

└──mywebapp.war


SVN + Jenkins + Maven automates the building and deployment of Java environments

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.