安装

官网上下载war包扔到tomcat的webapp下,启动tomcat即可

配置Gradle

Jenkins自动构建项目_Jenkins

Jenkins自动构建项目_Jenkins_02

push | merge自动构建

配置触发器

Jenkins自动构建项目_Jenkins_03

Gitlab添加WebHook

Jenkins自动构建项目_Jenkins_04

自动杀死上个进程并启动新的jar

杀死上个进程

#!/bin/sh

tomcat_id=`ps -ef | grep sso | grep -v "grep" | awk '{print $2}'`
echo $tomcat_id

for id in $tomcat_id
do
    kill -9 $id  
    echo "killed $id"  
done

启动新的进程

BUILD_ID=dontKillMe
nohup java -jar /root/.jenkins/workspace/邳州养老平台/default/pension-sso/build/libs/pension-sso-0.0.1-SNAPSHOT.jar

BUILD_ID=dontKillMe
nohup java -agentpath:/root/jrebel/lib/libjrebel64.so  -Drebel.remoting_port=18303  -Drebel.remoting_plugin=true  -Xms256m -Xmx256m  -Xdebug -Xrunjdwp:transport=dt_socket,address=18302,server=y,suspend=n -jar /root/.jenkins/workspace/邳州养老平台/default/pension-sso/build/libs/pension-sso-0.0.1-SNAPSHOT.jar > /opt/logs/sso/dev.log 2>&1 &

Idea配置可视化

Jenkins添加Token

/jenkins/user/用户/configure

Jenkins自动构建项目_Jenkins_05 复制生成的Token,就是访问密码

启用代理兼容

Jenkins自动构建项目_Jenkins_06Jenkins自动构建项目_Jenkins_07

获取Crumb

crumbIssuer/api/xml?tree=crumb#

Jenkins自动构建项目_Jenkins_08

配置idea

Jenkins自动构建项目_Jenkins_09Jenkins自动构建项目_Jenkins_10Jenkins自动构建项目_Jenkins_11