Jekins 自动化部署
Jekins 自动化部署 -windows
1、下载地址 :https://jenkins.io/download
2、cd d:/jenkins 将 jenkins.war 移动到该目录下
显示如下:
将C:\Users\hp466\.jenkins\secrets\initialAdminPassword 文件中的密码,复制到图中的输入框中,点击“continue”
4、安装缺少插件,按照提示步骤进行下一步(默认用户admin,密码见 上述文件initialAdminPassword)
5、进入首页
6、创建任务
7、建立文件夹 shell (打包脚本),脚本内容如下:
#!/bin/bashname="eurekaServer"
buildPath="$WORKSPACE/htest"
buildCMD="gradle bootRepackage"
buildResultPath="$buildPath/build/libs"
buildFile="htest.jar"
home="D:/runbin/jenkins6"
projectData=$home/data
log=$home/log/$name
config=$home/config/$name/application.yml
pro="java -Xmx256M -Xms256M -Dfile.encoding=utf-8 -jar $name.jar --spring.config.location=$config"
#打包
cd $buildPath
$buildCMD
#移动
mv $buildResultPath/$buildFile $projectData/$name.jar
sleep 3
#启动
cd $projectData
nohup $pro >> $log/run.log 2>&1 &
echo "$name has run"
进入htest,选择立即构建,则自动从git上拉取项目,并自动打包和运行。
9、浏览器访问http://127.0.0.1:8080 (端口为jar 配置的端口)