赞
踩
服务器 | ip |
---|---|
jenkins | 10.120.147.11 |
测试环境(tomcat) | 10.120.147.200 |
操作系统:CentOS7
Maven3.6.1:https://archive.apache.org/dist/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
Tomcat8:https://mirrors.bfsu.edu.cn/apache/tomcat/tomcat-8/v8.5.64/bin/apache-tomcat-8.5.64.tar.gz
Jenkins2.277.1:http://mirrors.jenkins.io/war-stable/2.277.1/jenkins.war
- # 10.120.147.11服务器
- # 安装jdk,配置java环境变量
- [root@bld147-11 src]# tar -xf jdk-8u271-linux-x64.tar.gz -C /opt
- [root@bld147-12 java]# ln -s /opt/jdk1.8.0_271/ /opt/jdk
-
- # 最后加上
- [root@bld147-11 src]# vi /etc/profile
- export JAVA_HOME=/opt/jdk
- export PATH=$JAVA_HOME/bin:$PATH
- export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
-
- [root@bld147-21 java]# . /etc/profile
- [root@bld147-11 src]# java -version
- java version "1.8.0_271"
- Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
- Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)
-
- # 安装maven,配置maven环境变量
- tar xf apache-maven-3.6.1-bin.tar.gz -C /opt
- ln -s /opt/apache-maven-3.6.1/ /opt/maven
-
- # maven配置
- # 设置国内镜像源
- vi /opt/maven/conf/settings.xml
- <mirror>
- <id>aliyun</id>
- <mirrorOf>*</mirrorOf>
- <name>Nexus aliyun</name>
- <url>http://maven.aliyun.com/nexus/content/groups/public</url>
- </mirror>
-
- # 配置maven环境变量
- vi /etc/profile
- export MAVEN_HOME=/opt/maven
- export PATH=${PATH}:${MAVEN_HOME}/bin
-
- . /etc/profile
-
- # 验证
- maven -v
- Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T15:00:29-04:00)
- Maven home: /opt/maven
- Java version: 1.8.0_271, vendor: Oracle Corporation, runtime: /opt/jdk1.8.0_271/jre
- Default locale: en_US, platform encoding: UTF-8
- OS name: "linux", version: "3.10.0-1127.el7.x86_64", arch: "amd64", family: "unix"
-
- # 安装git,这里采用yum的方式
- yum install -y git
- git --version
-
- # yum 安装git 根目录/usr/bin/git
- # 10.120.147.200服务器
- # 安装jdk,配置java环境变量
- [root@bld147-11 src]# tar -xf jdk-8u271-linux-x64.tar.gz -C /opt
- [root@bld147-12 java]# ln -s /opt/jdk1.8.0_271/ /opt/jdk
-
- # 最后加上
- [root@bld147-11 src]# vi /etc/profile
- export JAVA_HOME=/opt/jdk
- export PATH=$JAVA_HOME/bin:$PATH
- export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
-
- [root@bld147-21 java]# . /etc/profile
- [root@bld147-11 src]# java -version
- java version "1.8.0_271"
- Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
- Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)
- # 安装tomcat
- wget https://mirrors.bfsu.edu.cn/apache/tomcat/tomcat-8/v8.5.64/bin/apache-tomcat-8.5.64.tar.gz
- tar xf apache-tomcat-8.5.64.tar.gz -C /opt/
- ln -s /opt/apache-tomcat-8.5.64/ /opt/tomcat
- cd /opt/tomcat/bin/
- rm -rf *.bat
- ./startup.sh
登录之后先选择“推荐安装”,稍后自行安装相关插件
更改密码
admin/admin@123
- # jenkins安装插件
- Deploy to container
- Maven Integration
- GitHub Authentication
- GitHub Branch Source
- GitHub Organization Folder
- Publish Over SSH
- Subversion
Manage Jenkins -> Manage Plugins ->可选插件
系统管理 -> 全局工具设置(Global Tool Configuration),配置jdk.git,maven的根目录
10.120.147.11jenkinx服务器上的maven将开发产生的war包,通过SSH自动推送到远程tomcat服务器,需要手动配置ssh key。防止推送过程中输入密码。
- ssh-keygen
- ssh-copy-id -i 10.120.147.200
http://10.120.147.200:8080/test/hello
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。