windows下jenkins+Git+Gradle自动化部署

一:jenkins安装(jenkins.msi)

二:jenkins信息配置

1.修改主目录

windows下jenkins+Git+Gradle自动化部署_第1张图片

2.凭据

windows下jenkins+Git+Gradle自动化部署_第2张图片

 2.Global Tool Configuration

windows下jenkins+Git+Gradle自动化部署_第3张图片

 windows下jenkins+Git+Gradle自动化部署_第4张图片

三:jenkins项目配置

windows下jenkins+Git+Gradle自动化部署_第5张图片

 windows下jenkins+Git+Gradle自动化部署_第6张图片

 命令:

1.如果是gradle war包

echo 设置参数
set CATALINA_HOME=D:\tomcat\apache-tomcat-8.5.33
set PROJECT_NAME=XXX
set build_space=E:\workspace\jenkins\Jenkins.jenkins\jobs\%PROJECT_NAME%\workspace\build\libs

echo 删除之前存在的
cd /d %CATALINA_HOME%\bin
call shutdown.bat
cd /d %CATALINA_HOME%\webapps
if exist %PROJECT_NAME%.war del %CATALINA_HOME%\webapps\%PROJECT_NAME%.war
if exist %PROJECT_NAME%     rd /s/q %CATALINA_HOME%\webapps\%PROJECT_NAME%

echo 拷贝编译好的文件到tomcat
copy %build_space%\workspace.war %CATALINA_HOME%\webapps\
ren %CATALINA_HOME%\webapps\workspace.war %PROJECT_NAME%.war

echo 启动Tomcat
set BUILD_ID=dontKillMe
cd /d %CATALINA_HOME%\bin
call startup.bat

2.如果是maven jar包

@echo off
xcopy E:\workspace\jenkins\Jenkins.jenkins\jobs\xxx\workspace\target\xxx.jar D:\tomcat\apache-tomcat-8.5.33\webapps\ /Y
echo 复制xxx.jar完成

start java -jar D:\tomcat\apache-tomcat-8.5.33\webapps\xxx.jar
echo 后台启动jar

3. 重置序号 Script Console

item = Jenkins.instance.getItemByFullName("XXX项目名")
//THIS WILL REMOVE ALL BUILD HISTORY
item.builds.each() { build ->
  build.delete()
}
item.updateNextBuildNumber(1)

你可能感兴趣的:(安装与配置,jenkins)