Jenkins + Maven + Tomcat + SVN + Apache continuous integration

Source: Internet
Author: User
Tags version control system

Jenkins + Maven + Tomcat + SVN + Apache continuous integration

Jenkins + Maven + Tomcat + SVN + Apache continuous integration construction

I. Preface

1. Jenkins

Jenkins version book http://mirrors.jenkins-ci.org/

1.1 Jenkins continuous integration Introduction

Continuous Integration is a software development practice that provides a theoretical basis for improving software development efficiency and ensuring software development quality. Jenkins is an open-source software project designed to provide an open and easy-to-use software platform that enables continuous integration. This article starts with the basic concept of continuous integration and introduces how to quickly build a continuous integration environment based on Jenkins through specific examples.

Jenkins is an open source software project designed to provide an open and easy-to-use software platform that enables continuous software integration. Jenkins is easy to install, configure, and use.

1.2 meaning of continuous integration

1) Any part of continuous integration is automatically completed without too much manual intervention. This helps reduce repetitive processes to save time, costs, and workload;

2) continuous integration ensures that the Code submitted by team members at each time point can be successfully integrated. In other words, software integration problems can be discovered immediately at any point in time, making it possible to release deployable software at any time;

3) continuous integration can also benefit from the development trend of the software itself. This is especially important in scenarios with unclear requirements or frequent changes. The quality of continuous integration can help the team make effective decisions, at the same time, establish team confidence in product development.

1.3 continuous integration components

1) An Automatic Build Process, including automatic compilation, distribution, deployment, and testing;

2) A code repository that requires version control software to ensure code maintainability and serves as a material library for the building process, such as SVN and GIT code libraries;

3) a jenkins continuous Integration Server. The following 123.57.11.203 Server is a simple and easy-to-use continuous Integration Server.

2. Maven

1) Maven is a Project management tool that contains a Project Object Model, a set of standard sets, and a Project Lifecycle ), A Dependency Management System and logic used to run the plug-in (goal) defined in the lifecycle phase (phase. When you use Maven, you use a clearly defined project object model to describe your project. Then Maven can apply the cross-cutting logic, these logics come from a group of shared (or custom) plug-ins.

2) Maven has a life cycle, which is called when you run mvn install. This command tells Maven to execute a series of ordered steps until it reaches your specified lifecycle. One of the effects of traversing the lifecycle journey is that Maven runs many default plug-in targets that complete compilation and creation of a JAR file. You can easily manage project reports, generate sites, and manage JAR files.

3. Tomcat

1) Tomcat server is a free open-source Web application server, which is a lightweight application server. It is widely used in a small and medium-sized system and a few concurrent users, is the first choice for developing and debugging JSP programs. For a beginner, it can be thought that when an Apache server is configured on a machine, it can be used to respond to access requests on the HTML (an application under the standard General Markup Language) page. In fact, Tomcat is an extension of the Apache server, but it runs independently at runtime. Therefore, when you run tomcat, it actually runs independently as a process independent of Apache.

2) When the configuration is correct, Apache serves the HTML page, while Tomcat actually runs the JSP page and Servlet. In addition, like Web servers such as Tomcat and IIS, Tomcat can process HTML pages. In addition, it is a Servlet and JSP Container, and an independent Servlet container is the default mode of Tomcat. However, Tomcat cannot process static HTML as well as Apache servers.

4. SVN

SVN is short for Subversion. It is an open-source version control system. Compared with RCS and CVS, it adopts a branch management system. Its design goal is to replace CVS. Many version control services on the Internet have been migrated from CVS to Subversion. To put it simply, SVN is used for multiple people to jointly develop the same project and share resources.

Note that only Apache2.x compatibility is considered during SVN design. Therefore, Apache1.x cannot work normally.

5. Apache

Apache is the world's No. 1 Web server software. It can run on almost all widely used computer platforms. Because of its wide use of cross-platform and security, it is one of the most popular Web server software.

Differences between apache and Tomcat

Apache is a web server and Tomcat is an application (java) server. It is only a servlet container and is an extension of Apache. Both Apache and Tomcat can be run as independent web servers, but Apache cannot interpret java programs (jsp and serverlet ). Apache is a common server and only html is supported. However, you can use the plug-in to support php and connect to Tomcat (one-way Apache connection to Tomcat means you can access Tomcat resources through Apache. Otherwise ). The two are both a container, but the publishing is different: Apache is an html container with functions like IIS; Tomcat is a jsp/servlet container for publishing jsp and java, similar to IBM webshere, EBA Weblogic, and sun JRun. Apache and Tomcat are independent and can be integrated on a single server. Apache only supports static Web pages, but dynamic web pages such as asp, php, cgi, and jsp must be processed by Tomcat.
For example, Apache is a truck with some things such as html. But you cannot hold water. To hold water, you must have a container (bucket). Tomcat is a bucket (such as Java), and this bucket can not be placed on a truck.
Integrated Use of Apache and Tomcat: if the client requests a static page, the Apache server only needs to respond to the request. If the client requests a dynamic page, the Tomcat server responds to the request; because jsp is interpreted on the server side, so integration can reduce Tomcat service overhead.

Ii. Download URL and installation environment

1. Download URL

Https://jenkins.io/download/ jenkins. war (WAR package)

Https://pkg.jenkins.io/redhat/ Jenkins (RPM package)


Https://pkg.jenkins.io/debian-stable/ Jenkins (DEB package)

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

Https://tomcat.apache.org/download-80.cgi Tomcat downloading

Http://www.oracle.com/technetwork/java/javase/downloads/index.html JDK download

2. installation environment in this case

OS: Ubunutu 17.04
IP: 192.168.44.132 (Tomcat + JDK + Jenkins + Maven)
IP: 192.168.44.small (SVN + Apache)
In this case, jenkins. war is used in combination with Tomcat. The war package is used and the deb package is not used.
Apache-maven-3.5.2-bin.tar.gz
Apache-tomcat-8.5.24.tar.gz
Jdk-8u151-linux-x64.tar.gz
SVN and Apache SVN source code are very troublesome. We recommend that you install apt-get and install Apache with apt-get.

Iii. Install software

IP: 192.168.44.132

Tar zxvf jdk-8u151-linux-x64.tar.gz-C/usr/local/
Tar zxvf apache-tomcat-8.5.24.tar.gz-C/usr/local/
Tar zxvf apache-maven-3.5.2-bin.tar.gz-C/usr/local/

Vi/etc/profile

Set Java Variables

Export JAVA_HOME =/usr/local/jdk1.8.0 _ 151
Export JRE_HOME =/usr/local/jdk1.8.0 _ 151/jre
Export PATH =/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games: /usr/local/games:/usr/local/jdk1.8.0 _ 151/bin
Export CLASSPATH =./:/usr/local/jdk1.8.0 _ 151/lib:/usr/local/jdk1.8.0 _ 151/jre/lib

Set maven Variables

Export MAVEN_HOME =/usr/local/apache-maven-3.5.2
Export PATH =$ {MAVEN_HOME}/bin: $ {PATH}

Refresh variable

./Etc/profile

View Java Information

Root @ Ubuntu:/usr/local # java-version

Java version "1.8.0 _ 151"
Java (TM) SE Runtime Environment (build 1.8.0 _ 151-b12)
Java HotSpot (TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

View maven version

Root @ ubuntu:/usr/local # mvn-v

Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T15: 58: 13 + 08: 00)
Maven home:/usr/local/apache-maven-3.5.2
Java version: 1.8.0 _ 151, vendor: Oracle Corporation
Java home:/usr/local/jdk1.8.0 _ 151/jre
Default locale: en_HK, platform encoding: UTF-8
OS name: "linux", version: "4.10.0-19-generic", arch: "amd64", family: "unix"

Test whether Tomcat is normal

/Usr/local/apache-tomcat-8.5.24/bin/startup. sh

In the browser window, enter http: // 192.168.44.132: 8080/

Disable Tomcat

/Usr/local/apache-tomcat-8.5.24/bin/shutdown. sh

Jenkins Configuration

Mkdir-p/data/postmall/tomcat/webapps

Mv/usr/local/jenkins. war/data/postmall/tomcat/webapps/

In this example, the default Tomcat port is changed to 8888, And the appBase path is changed to/data/postmall/tomcat/webapps. For example, restart Tomcat after modification, under/data/postmall/tomcat/webapps, you can see that there is an additional jenkins directory, and the war package has been unlocked.

AppBase in Tomcat, which indicates:
1. The subdirectories under this directory will be automatically deployed as applications.
2. The. war file under this directory will be automatically decompressed and deployed as an application.

The testing environment in a company is generally a container that runs multiple projects, and a production environment is a container that runs one project.

Let's take a look at our testing environment.

Let's take a look at the production environment of our company.

Access on web pages

Http: // 192.168.44.132: 8888/jenkins

Dialog Box

Username: admin

Password: copy the encrypted string in initialAdminPassword.

Files are stored in/root/. jenkins/secrets/initialAdminPassword by default and encrypted. In this example, root users are used.

It is recommended to change the production environment to another directory, please refer to my another document https://www.bkjia.com/Linux/2018-03/151350.htm

So far, the software 192.168.44.132 has been installed.

IP: 192.168.44.small

I. Install software

Apt-get install apache2
Apt-get install subversion
Apt-get install libapache2-svn

After the above installation, you can directly access the apache homepage, such as http: // localhost/

Command Line curl-I-m 15-o/dev/null-s-w % {http_code} localhost

For curl usage, please refer to the curl use instance detailed https://www.bkjia.com/Linux/2017-12/149659.htm

Ii. SVN Configuration

1. Create a svn Repository

1) Create the svn Directory: mkdir-p/home/. svn/svnrepos/project (use the hidden directory to make it safer)

2) create a repository project: svnadmin create/home/. svn/svnrepos/project. After execution, the project directory contains directories and files created by svnadmin.

2. configure and manage svn

1) The repository configuration file is under/home/. svn/svnrepos/project/conf/, and the configuration file is backed up first. Note: the rows of the following configuration items must be the top level; otherwise, an error is returned.

Cd/home/. svn/svnrepos/project/& mkdir conf. bak & cp-rf conf/* conf. bak/& vi conf/svnserve. conf

The configuration item is under [general:

Anon-access: anonymous user permissions, which can be set to read, write, or none. The default value is read. Anonymous user access not allowed: anon-access = none

Auth-access: Authenticate the user's permissions, which can be read, write, or none. The default value is write.

Password-db: the path of the password database. Remove the front #.

Authz-db: Path of the authentication rule repository. Remove the # from the front #.

Realm =/home/. svn/svnrepos/project warehouse directory. Remove the previous # And do not modify it by default.

2) configure the passwd file

This is the password file for each user. It is relatively simple, that is, "user name = password", using a clear code. For example:

Allen = 111111

Bllename = 222222

Ellen = 333333

3) configure the authz File

[Groups] section: to facilitate management, you can put some users in a group, such as: owner = allen, bllen

The sections under the groups table indicate the authentication rules for a directory. For example, the section of the authentication rules for the root directory is [/]. When setting authentication rules for a single user, add a row at the end of the user, for example:

[/]

Allen = rw # allen's permission for the root directory is rw

Bllen = rw # The bllen permission to the root directory is rw

Ellen = r # The bllen permission for the root directory is r

If a group is used, add @ before the group name and add @ at the end.

[/]

@ Owner = rw # all users in the group owner are rw, which is equivalent to allen = rw and bllen = rw.

* = R # All Users except allen and bllen are read-only


3. Start and Stop the svn Service

1). Start:

Start from the svnrepos directory. svnserve-d-r/home/. svn/svnrepos/project. The root directory [/] is the project

2). Test Access:

Enter svn: // 192.168.44.loud in the browser, and enter the username and password in the pop-up window.

3). Stop:

Killall svnserve

In short, the root directory (/) of each warehouse is its own starting directory. [/] is suitable for a single warehouse and cannot set permissions across warehouses.

Use of client SVN see my other article https://www.bkjia.com/Linux/2018-03/151351.htm

If SVN cannot be accessed when started, check whether the user name and password in the configuration file are correct. You can also try to delete all saved records in settings-saved data and try again.

4). Modify the port

Modify apache2 Port

Root @ ubuntu:/etc/apache2 # vi ports. conf

Listen port # The port you want

<IfModule ssl_module>

Listen 443.

</IfModule>

 

<IfModule mod_gnutls.c>

Listen 443.

</IfModule>

If you want to modify the default SVN Port

Re-specify a port number (default port 3690), for example, change it to 3691.
Svnserve-d-listen-port 3691-r/home/. svn/svnrepos/project

Restart/etc/init. d/apache2 restart after Configuration

For example, put 333.txt in the test folder. If you try to submit the file, the system prompts that the Verification Failed. Because the ellen user is given the read permission and cannot be written, you can use allen and bllen.

So far, the 192.168.44.small software has been installed.

This article permanently updates link: https://www.bkjia.com/Linux/2018-03/151352.htm

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.