jenkins +gitlab +docker 自动化部署tomcat 项目
实验环境
实验设备
三台服务器
centos 7.X 以上
内存 2-3G左右
192.168.1.195 (jenkins最新+ git 2.8+maven 3.5 +tomcat 8+java1.8 )
192.168.1.196 (git2.8 + gitlab 10.0.0 账号关联)
192.168.1.97 (docker 17.3 ce 社区版 +)
gitlab 版本查看
[root@git ~]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
10.0.0
一.初始化系统
三台机器都需要操作
# 设置主机名
hostnamectl set-hostname jenkins (主机名根据各个服务更改)
# 时间同步
yum -y install ntp
systemctl enable ntpd
systemctl start ntpd
ntpdate -u cn.pool.ntp.org
hwclock --systohc
timedatectl set-timezone Asia/Shanghai
# 关闭swap分区
echo "vm.swappiness = 0">> /etc/sysctl.conf
sysctl -p
swapoff -a && swapon -a
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
二.jenkins 安装
192.168.1.195
1.先安装jdk
tar xf jdk-8u181-linux-x64.tar.gz
mv jdk-8u181-linux-x64 java
配置java 环境变量
cat >> /etc/profile << EOF
JAVA_HOME=/usr/local/java
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH
EOF
source /etc/profile
2.配置tomcat
tar xf apache-tomcat-8.5.34.tar.gz
mv apache-tomcat-8.5.34 tomcat
3.配置git
https://www.cnblogs.com/zoulixiang/p/9805619.html
4.配置maven
apache-maven-3.5.3-bin.tar.gz
tar xf apache-maven-3.5.3-bin.tar.gz
cat >> /etc/profile << EOF
export MAVEN_HOME=/usr/local/apache-maven-3.5.3
export PATH=${MAVEN_HOME}/bin:${PATH}
export PATH=/usr/local/git/bin:$PATH
EOF
source /etc/profile