1. Create a new virtual machine to install Tomcat
(1) Install JDK website download jdk:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html download jdk8, put to/ Under the usr/local/src/directory [[Email protected] ~]# tar -zxvf jdk-8u151-linux-x64.tar.gz[[email protected] ~]# mv jdk1.8.0_151 /usr/local/jdk1.8[[email protected] ~]# vim /etc/profile Add the following content: java_home=/usr/local/jdk1.8/java_bin=/usr/local/jdk1.8/binjre_home=/usr/ Local/jdk1.8/jrepath= $PATH:/usr/local/jdk1.8/bin:/usr/local/jdk1.8/jre/binclasspath=/usr/local/jdk1.8/jre/lib :/usr/local/jdk1.8/lib:/usr/local/jdk1.8/jre/lib/charsets.jar[[email protected] ~]# source /etc/profile[[email protected] ~]# java -versionjava version "1.8.0_151" Java (tm) SE Runtime Environment (BUILD&NBSP;1.8.0_151-B12) Java hotspot (tm) 64- bit server vm (Build 25.151-b12, mixed mode) (2) Install tomcat[[email protected] ~]# wget http://apache.fayea.com/tomcat/tomcat-8/v8.5.20/bin/apache-tomcat-8.5.20.tar.gz[[email protected] ~]# tar -zxvf apache-tomcat-8.5.24.tar.gz [[email protected] ~]# mv apache-tomcat-8.5.24 /usr/local/tomcat[[email protected] ~]# /usr/local/tomcat/bin/ startup.sh [[email protected] ~]# netstat -tulnp |grep 8080tcp6 0 0 :::8080 :::* LISTEN 3765/java tip: Three port 8080 is the port that provides the Web service, 8005 is the management port, and 8009 port is the port that the third-party service calls. For example, httpd and Tomcat will use the (3) configuration tomcat[[email protected] ~]# vim /usr/local/tomcat/conf/ Tomcat-users.xml <tomcat-users><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=" admin123456 " roles=" Admin,manager,admin-gui,admin-script,manager-gui,manager-script, Manager-jmx,manager-status " /></tomcat-users>[[email protected] ~]# /usr/local/ tomcat/bin/shutdown.sh [[email protected] ~]# /usr/local/tomcat/bin/startup.sh When you access tomcat, clicking "Manager webapp" will jump out of a verification pop-up box and enter your username and password
Will jump to the following interface, indicating that the user name password is correct,
2. Download Zrlog Java code push to Gitlab
(1) Download Zrlog code [[email protected] home]# wget https://codeload.github.com/94fzb/zrlog/zip/ Master--2017-12-25 11:02:45-- https://codeload.github.com/94fzb/zrlog/zip/masterresolving codeload.github.com (codeload.github.com) ... 192.30.255.121, 192.30.255.120connecting to codeload.github.com (codeload.github.com) |192.30.255.121|:443... connected. http request sent, awaiting response... 200 oklength: unspecified [ application/zip]saving to: ' master ' [ <=> ] 1,669,502 199KB/s in 8.6s 2017-12-25 11:02:56 (189 kb/s) &NBSP;-&NBSP; ' Master ' saved [1669502][[email protected] home]# du -sh1.7m. [[Email protected] home]# du -sh master1.6mmaster (2) Unzip [[email protected] home]# yum install -y unzip[[email protected] home]# unzip Master (3) initialize the repository and push the Zrlog code to gitlab[[email protected] home]# mkdir java[[email Protected] java]# mv zrlog-master/* java/[[email protected] java]# git remote add orgin [email protected]:java/zrlog.git[[email protected] java]# git add . [[email protected] java]# git commit -m "Add origin" # On branch masternothing to commit, working directory clean[[email protected] java]# lltotal 48drwxr-xr-x 2 root root 55 dec 25 17:45 Bin-rw-r--r-- 1 root&nBsp;root 6114 dec 25 17:45 changelog.mddrwxr-xr-x 2 root root 42 Dec 25 17:45 doc-rw-r--r-- 1 root root 11358 Dec 25 17:45 license-rwxr-xr-x 1 root root 6468 dec 25 17:45 Mvnw-rw-r--r-- 1 root root 4994 dec 25 17:45 mvnw.cmd-rw-r--r-- 1 root root 7664 dec 25 17:45 pom.xml-rw-r--r-- 1 root root 3574 dec 25 17:45 readme.mddrwxr-xr-x 4 root root 28 dec 25 17:45 src[[email protected] Java]# git push origin mastercounting objects: 457, done.compressing objects: 100% (426/426), done. writing objects: 100% (457/457), 2.98 mib | 1.72 mib/s, done. total 457 (delta 51), reused 0 (delta 0) remote: resolving deltas: 100% (51/51), done. To [email protected]:java/zrlog.git* [new branch] master -> master
3. Create a new MAVEN project Zr_blog
(1)
Login to Jenkins, click "New", Task Name customization (zr_blog)
Select "Build a Maven project"
Click "OK"
(2)
SOURCE Management
Choose "git", Repository URL to fill in your Git address, and configure the corresponding key, we'd better first in Jenkins this machine can directly remote GIT operation private Warehouse
Build triggers, build environments, Pre steps keep the default
Build
"Root POM" for Pom.xml, goals and options fill in clean install-d maven.test.skip=true
Post Steps, build settings remain default
Post-build actions
Click "Add Post Build Action" select "Deploy war/ear to a container", "war/ear files" fill in "**/*.war", Contex path is left blank, containers select Tomcat 8.x, Tomcat URL fill in the URL of the machine that you want to publish the war package to, such as http://192.168.56.13:8080
Credentials here you need to click Add on the right, adding username and password
Click "Build Now" to view the console information,
3, see the Linux-node3 WebApps directory, there will be a corresponding war package, and has been decompressed, using the browser to access
[Email protected] ~]# Ll/usr/local/tomcat/webapps/total 7160drwxr-x---root root 4096 Dec 03:08 docsdrwxr-x--- 6 root root 4096 Dec 03:08 examplesdrwxr-x---5 root root 4096 Dec 03:08 host-managerdrwxr-x---6 root root 4096 Dec 04:05 managerdrwxr-x---3 root root 4096 Dec 03:08 rootdrwxr-x---9 root root 4096 Dec 25 04:04 Zrlog-1.8.0-rw-r-----1 root root 7306944 Dec 04:04 Zrlog-1.8.0.war
Automating deployment of publishing Java projects to Tomcat