编译环境
运行环境
编译环境
1,编译环境(jenkins服务器上部署)
#需要安装java(略,安装jenkins已安装java)
# 编译环境(jenkins服务器上部署)
[root@\ jenkins~]# wget https://mirrors.aliyun.com/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
--2021-04-16 18:54:04-- https://mirrors.aliyun.com/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 42.236.78.213, 42.236.78.209, 42.236.78.206, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|42.236.78.213|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9506321 (9.1M) [application/octet-stream]
Saving to: ‘apache-maven-3.6.3-bin.tar.gz’
100%[==========================================================================================================>] 9,506,321 8.28MB/s in 1.1s
2021-04-16 18:54:05 (8.28 MB/s) - ‘apache-maven-3.6.3-bin.tar.gz’ saved [9506321/9506321]
[root@\ jenkins~]# tar -xf apache-maven-3.6.3-bin.tar.gz -C /usr/local/
[root@\ jenkins~]# vim /etc/profile
[root@\ jenkins~]# source /etc/profile
# 测试mvn
[root@\ jenkins~]# mvn --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/apache-maven-3.6.3
Java version: 1.8.0_282, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-1.el7_9.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.21.1.el7.x86_64", arch: "amd64", family: "unix"
2,配置jenkins+maven
JAVA_HOME
[root@\ jenkins~]# cd /usr/lib/jvm/java-1.8.0-openjdk
[root@\ jenkins/usr/lib/jvm/java-1.8.0-openjdk]# pwd
/usr/lib/jvm/java-1.8.0-openjdk
设置环境变量
3,安装maven插件
4,创建代码仓库
5,创建maven仓库
# 在Jenkins服务器上创建
[root@\ jenkins/opt]# cd /usr/local/apache-maven-3.6.3/conf/
[root@\ jenkins/usr/local/apache-maven-3.6.3/conf]# vim settings.xml
<!--本地仓库-->
<localRepository>/data/software/repository</localRepository>
<mirrors>
<!--阿里云镜像-->
<mirror>
<id>aliyun-maven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven mirror</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
</mirrors>
[root@\ jenkins~]# mkdir -pv /data/software/repository
mkdir: created directory ‘/data/software’
mkdir: created directory ‘/data/software/repository’
[root@\ jenkins~]# chown jenkins.jenkins /data/software/repository/
6,测试编译
[root@\ jenkins]# cd springboot/
[root@\ jenkins/var/lib/jenkins/workspace/jenkins_java/springboot]# ll
-rwxr-xr-x 1 jenkins jenkins 10070 Apr 19 16:03 mvnw
-rw-r--r-- 1 jenkins jenkins 6608 Apr 19 16:03 mvnw.cmd
-rw-r--r-- 1 jenkins jenkins 1664 Apr 19 16:03 pom.xml
drwxr-xr-x 4 jenkins jenkins 30 Apr 19 16:03 src
drwxr-xr-x 10 jenkins jenkins 266 Apr 19 16:07 target
[root@\ jenkins/var/lib/jenkins/workspace/jenkins_java/springboot]# cd target/
[root@\ jenkins/var/lib/jenkins/workspace/jenkins_java/springboot/target]# ll
total 27944
drwxr-xr-x 3 jenkins jenkins 47 Apr 19 16:07 classes
drwxr-xr-x 3 jenkins jenkins 25 Apr 19 16:06 generated-sources
drwxr-xr-x 3 jenkins jenkins 30 Apr 19 16:07 generated-test-sources
drwxr-xr-x 4 jenkins jenkins 37 Apr 19 16:07 GitLab-0.0.1-SNAPSHOT
-rw-r--r-- 1 jenkins jenkins 17055419 Apr 19 16:07 GitLab-0.0.1-SNAPSHOT.war
-rw-r--r-- 1 jenkins jenkins 11558066 Apr 19 16:07 GitLab-0.0.1-SNAPSHOT.war.original
drwxr-xr-x 2 jenkins jenkins 28 Apr 19 16:07 maven-archiver
drwxr-xr-x 3 jenkins jenkins 35 Apr 19 16:06 maven-status
drwxr-xr-x 2 jenkins jenkins 117 Apr 19 16:07 surefire-reports
drwxr-xr-x 3 jenkins jenkins 17 Apr 19 16:07 test-classes
GitLab-0.0.1-SNAPSHOT.war 为编译后的包
运行环境
1,安装tomcat
[root@\ web03/opt]# yum install java-1.8.0-openjdk* -y
[root@\ web03/opt]# wget https://ftp.wayne.edu/apache/tomcat/tomcat-9/v9.0.45/bin/apache-tomcat-9.0.45.tar.gz
[root@\ web03/opt]# tar -xf apache-tomcat-9.0.45.tar.gz -C /usr/local/
[root@\ web03/opt]# /usr/local/apache-tomcat-9.0.45/bin/startup.sh
2,修改配置
# 粘贴在最后一行</tomcat-users>的前面
[root@\ web03/opt]# vim /usr/local/apache-tomcat-9.0.45/conf/tomcat-users.xml
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager-script"/>
<role rolename="manager-gui"/>
<role rolename="manager-status"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<user username="tomcat" password="tomcat" roles="manager-gui,manager-script,tomcat,admin-gui,admin-script"/>
# 注释掉,允许所有端口访问(在公司换成内网地址)
[root@\ web03/opt]# vim /usr/local/apache-tomcat-9.0.45/webapps/manager/META-INF/context.xml
<!--<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />-->
#重启
[root@\ web03/opt]# /usr/local/apache-tomcat-9.0.45/bin/shutdown.sh
Using CATALINA_BASE: /usr/local/apache-tomcat-9.0.45
Using CATALINA_HOME: /usr/local/apache-tomcat-9.0.45
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-9.0.45/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/apache-tomcat-9.0.45/bin/bootstrap.jar:/usr/local/apache-tomcat-9.0.45/bin/tomcat-juli.jar
Using CATALINA_OPTS:
[root@\ web03/opt]# /usr/local/apache-tomcat-9.0.45/bin/startup.sh
Using CATALINA_BASE: /usr/local/apache-tomcat-9.0.45
Using CATALINA_HOME: /usr/local/apache-tomcat-9.0.45
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-9.0.45/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/apache-tomcat-9.0.45/bin/bootstrap.jar:/usr/local/apache-tomcat-9.0.45/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
再次访问
用户和密码都是tomcat,
图1所示
图锁对应的内容,即为以下目录下的内容
[root@\ web03/usr/local/apache-tomcat-9.0.45]# cd webapps/
[root@\ web03/usr/local/apache-tomcat-9.0.45/webapps]# ll
total 4
drwxr-x--- 15 root root 4096 Apr 18 21:11 docs
drwxr-x--- 7 root root 99 Apr 18 21:11 examples
drwxr-x--- 6 root root 79 Apr 18 21:11 host-manager
drwxr-x--- 6 root root 114 Apr 18 21:11 manager
drwxr-x--- 3 root root 223 Apr 18 21:11 ROOT