jenkins deploy java project (five)

A, web server installation jdk + tomcat jdk which can openjdk, version 1.8

1.1 installation jdk environment

1: Direct use yum install openjdk
# yum install -y java-1.8.0*

Second way: installed locally oracle official website to download the installation package rpm:
# yum  localinstall jdk-8u92-linux-x64.rpm

Three ways: download binary packages custom profile environment variables:
Download: HTTP: // www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 

# tar . Xvf the JDK-8u121-Linux-x64 tar .gz -C / usr / local / 
# LN -sv / usr / local / jdk1. . 8 .0_121 / usr / local / JDK
# vim /etc/profile
 export HISTTIMEFORMAT="%F %T `whoami` "
 export JAVA_HOME=/usr/local/jdk
 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
 export PATH=$PATH:$JAVA_HOME/bin

# source  /etc/profile
# java -version
Version java " 1.8.0_121 "     # may appear to confirm the current version of java
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

1.2 Installation tomcat environment

# 1. 安装tomcat
wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.42/bin/apache-tomcat-8.5.42.tar.gz
tar xf apache-tomcat-8.5.42.tar.gz 
mv apache-tomcat-8.5.42 /usr/local/
ln -s /usr/local/apache-tomcat-8.5.42/ /usr/local/tomcat

# 2 . Open the administration page, set the user name and password
vim /usr/local/tomcat/conf/tomcat-users.xml
Last in line # </ tomcat-users> front and add the following
 <Role rolename = " ADMIN " />
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="manager"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user name="admin" password="123456" roles="admin,manager,admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status" />

# 3 . Modify allow access to the list of IP addresses, allowing 192. 168.7 . * IP range
vim /usr/local/tomcat/webapps/manager/META-INF/context.xml
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|192.168.7.*" />

# 4 . Start Tomcat
 / usr / local / Tomcat / bin / the Startup. SH

1.3 Access management interface is as follows:

http://192.168.7.83:8080/manager/html

Two, jenkins server installation jdk and maven

jdk see above mounting method, the following mounting method is maven

Software Download: https: //maven.apache.org/download.cgi

# 1. Install download and install Maven
wget
HTTP: // mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz tar Apache-maven-XF 3.6 . . 1 -bin. the tar .gz -C / usr / local / LN -s / usr / local / Apache-maven- 3.6 . . 1 / / usr / local / Maven # 2. Add the environment variable vim /etc/profile PATH=/usr/local/maven/bin/:$PATH source /etc/profile

Third, globally tool configured on jenkins web page

System Management -> Global Configuration Tools -> maven configuration, jdk, maven

Fourth, check the installation Maven Integration and Deploy to container plug

System Management -> Plugin Manager -> Optional plug-ins - after restarting jenkins> installation is complete

# After the installation is complete, manually restart Jenkins 
systemctl restart Jenkins

 Fifth, build maven project

After you have installed above 5.1 plug-in, then click on the new job will be more time "to build a maven project"

5.2 configuration code repository, this code is a hello world demo war package

Download: link: https: //pan.baidu.com/s/1kmrsglMGi8kyZZqDN31bUw extraction code: wrot

5.3 Configuration build

maven clean install on behalf of two different phases of lifecycle,
Clean: remove compiled files, such as target directory file,
install the source code package and said it would put local repository (usually .m2 / Repository)
-D representation of maven maven.test.skip = true mean operating parameter skip unit directly test package (Maven lifecycle is normal to test repackager)

5.4 Construction increase Step: Deploy war / ear to a container

5.5 Construction of the project immediately

 

5.6 Test Access

 

Reproduced in: https: //www.cnblogs.com/cyleon/p/11064608.html

Guess you like

Origin blog.csdn.net/weixin_33766805/article/details/93744089