持续集成
1服务器部署jdk1.8配置环境变量
2解压maven的包放在对应的路径
(1) 配置maven,修改配置文件的仓库地址settings.xml
<localRepository>E:/Maven/bskj</localRepository>
3安装jenkins2.346.1
(1) 安装后,选择推荐插件
(2) 安装后进入jenkins
(3) 修改admin的密码为123456
4安装插件
(1) 安装Localization: Chinese (Simplified)版本1.0.24翻译中文插件
(2) Deploy to container Plugin(自动化部署插件)
(3) Maven Integration Plugin(Maven集成插件)
(4) Publish Over SSH Plugin(SSH远程发布插件)
(6) Pipeline Maven Integration
(7) Maven Release Plug-in版本0.16.3
5应用服务器安装ssh服务
(1)复制文件夹 OpenSSH-Win64.zip解压后将文件夹复制到C:\Program Files目录下
(2)安装
使用cmd进行安装,以64位为例
(1cd进入C:\Program Files\OpenSSH-Win64目录下
(2输入命令回车: powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1
(3继续输入命令回车: netsh advfirewall firewall add rule name=sshd dir=in action=allow protocol=TCP localport=22
(4输入命令回车,打开: net start sshd
(3)配置环境变量
将C:\Program Files\OpenSSH-Win64放入系统变量Path下即可
(4)、测试
cmd中输入ssh,如果显示如下界面,则证明安装成功了
6jenkins的相关配置
System Configuration配置
Global Tool Configuration配置
配置项目
clean package -Dmaven.test.skip=true
@echo off
set port=9003
for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%port%"') do (
echo kill the process %%m who use the port
taskkill /pid %%m -t -f
goto start
)
:start
if exist "C:\jenkins\haems-1.0.war" del "C:\jenkins\haems-1.0.war"
echo delFileSuccess
copy "C:\workspace\target\haems-1.0.war" "C:\jenkins\haems-1.0.war"
echo copyFileSuccess
start "haems" java -Dfile.encoding=utf-8 -jar C:\jenkins\haems-1.0.war --spring.profiles.active=prod > C:\jenkins\haems-1.0.log 2>&1 &
echo good bye
exit 0
7打包
执行Build Now
7打包