一、部署git
1.安装依赖包
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker –y
2.官网下载需要的git包
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.34.4.tar.gz
3.安装git
tar –xvzf git-2.34.4.tar.gz cd git-2.34.4/ make prefix=/usr/local/git all make prefix=/usr/local/git install vim /etc/bashrc PATH=$PATH:$HOME/bin:/usr/local/git/bin source /etc/bashrc git --version
二、部署jdk环境
1.传好jdk8的包
jdk-8u211-linux-x64.tar.gz
2.解压安装jdk
tar xvzf jdk-8u211-linux-x64.tar.gz -C /usr/local/ cd /usr/local/ mv jdk-8u211-linux-x64.tar.gz jdk
3.修改环境变量
vim /etc/bashrc JAVA_HOME=/usr/local/jdk export PATH=$PATH:$JAVA_HOME/bin source /etc/bashrc
4.测试jdk
Java –version java version "1.8.0_211" Java(TM) SE Runtime Environment (build 1.8.0_211-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
三.部署maven
1.下载和解压maven
wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.65/bin/apache-tomcat-9.0.65.tar.gz tar –xvzf apache-tomcat-9.0.65.tar.gz –C /usr/local/ mv /usr/local/ apache-tomcat-9.0.65.tar.gz/ /usr/local/tomcat
2.修改环境变量
vim /etc/bashrc export M2_HOME=/usr/local/maven export M2=$M2_HOME/bin PATH=$M2:$PATH:$HOME/bin:/usr/local/git/bin export JAVA_HOME=/usr/local/jdk export PATH source /etc/bashrc
3.测试maven
mvn –version Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: /usr/local/maven Java version: 1.8.0_211, vendor: Oracle Corporation, runtime: /usr/local/jdk/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.10.0-1127.el7.x86_64", arch: "amd64", family: "unix"
四.部署tomcat
1.下载解压tomcat
wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.65/bin/apache-tomcat-9.0.65.tar.gz tar –xvzf apache-tomcat-9.0.65.tar.gz –C /usr/local/ mv /usr/local/ apache-tomcat-9.0.65.tar.gz/ /usr/local/tomcat
2.配置tomcat环境变量
vim /etc/profile CATALINA_HOME=/usr/local/tomcat export CATALINA_HOME source /etc/profile
3.启动tomcat
/usr/local/tomcat/bin/startup.sh
4.测试tomcat
http://ip:8080 (ip为jenkins的ip地址,能看到tomcat页面为成功。)
/usr/local/tomcat/bin/shutdown.sh
五.部署jenkins服务
1.下载jenkins的war包
wget http://updates.jenkins-ci.org/download/war/2.346.1/jenkins.war cp jenkins.war /usr/local/tomcat/webapps/ /usr/local/tomcat/bin/startup.sh (启动tomcat后,主页下的war包会自动解压,注意名称一定为jenkins.war)
2. 通过yum的方式安装(推荐)
#安装 yum install jenkins -y # 查看服务状态 systemctl status jenkins.service # 启动服务 systemctl start jenkins.service # 停止服务 systemctl stop jenkins.service
六.部署jenkins前端配置
1.访问jenkins地址登录管理员账户
访问http://ip:8080/jenkins (用可以连通的主机访问)
cat /root/.jenkins/secrets/initialAdminPassword
(服务器后端查看密码,一串代码为管理员初始密码)
2.默认安装插件,等待所有安装完成。
3.创建初始用户
4.进入jenkins主页
七.安装jenkins的插件
安装Deploy to container,Maven Integration,GitHub Authentication,GitHub Branch Source,GitHub Organization Folder,Publish Over SSH插件。
1.选择系统管理
2.选择插件管理
3.选择需要的插件安装
选中后选择更新完重启服务
Deploy to container(支持自动化将代码部署到tomcat容器)
Maven Integration(jenkins 利用maven编译,打包,所需插件)
GitHub Authentication(git插件)
GitHub Branch Source(git插件)
GitHub Organization Folder(git插件)
Publish Over SSH(ssh传输到另一台服务器)
八.Jenkins全局配置
1.配置jdk
2.配置git目录
3.配置maven
九.Jenkins新建任务
1.General
2.源码管理-图为公有仓库
3.构建触发器
4.Build
clean package -Dmaven.test.skip=true
5.构建后操作
target/*.war target /jenkins/war /jenkins/sh/deploy.sh Name(ssh server 因为之前的配置会默认出现tomcat业务服务器的名字) source file(构建之后,在jenkins服务器上是可以自动看到war包的。(该路径不需要创建)) Remove prefix(此文件夹将位于全局配置中的文件夹,需要手动创建) Exec command(为tomcat服务器接收源代码后执行的动作,比如:将源码拷贝到网站的主目录(/jenkins),并执行一些其他操作如重启服务器等(或创建文件touch)(需要后台创建)deploy.sh脚本自己编写。 mkdir -p /jenkins/war mkdir /jenkins/sh cat /jenkins/sh/deploy.sh cp -r /jenkins/war/*.war /jenkins touch /tmp/aaaaaa.txt chmod +x /jenkins/sh/deploy.sh
十.Jenkins构建任务
1.立即构建
2.构建完成
Vue3中CSS用法(scoped、选择器、module、v-bind)
2024-02-18