From 8d40216b01e307449c289836a91034a3f63de7d0 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Fri, 19 Jul 2024 12:34:22 +0800 Subject: [PATCH] deploy --- scripts/deploy.sh | 86 ++++++++++++++++++++++++++++++++++++++++----- scripts/pipeline.sh | 24 ++++++------- 2 files changed, 90 insertions(+), 20 deletions(-) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index f892751e..3b0b9d9e 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -9,19 +9,31 @@ echo "workspace is ${WORKSPACE}" mv ${WORKSPACE}/sgzb-auth/target/sgzb-auth.jar $deploy_path mv ${WORKSPACE}/sgzb-gateway/target/sgzb-gateway.jar $deploy_path mv ${WORKSPACE}/sgzb-modules/sgzb-system/target/sgzb-modules-system.jar $deploy_path +mv ${WORKSPACE}/sgzb-modules/sgzb-base/target/sgzb-modules-base.jar $deploy_path +mv ${WORKSPACE}/sgzb-modules/sgzb-file/target/sgzb-modules-file.jar $deploy_path +mv ${WORKSPACE}/sgzb-modules/sgzb-material/target/sgzb-modules-material.jar $deploy_path chmod 777 *.jar echo "--------moveFile end--------------" export sgzb_auth_enable=true export sgzb_gateway_enable=true export sgzb_modules_system_enable=true +export sgzb_modules_base_enable=true +export sgzb_modules_file_enable=true +export sgzb_modules_material_enable=true export sgzb_auth_jar=sgzb-auth.jar export sgzb_gateway_jar=sgzb-gateway.jar export sgzb_modules_system_jar=sgzb-modules-system.jar +export sgzb_modules_base_jar=sgzb_modules_base.jar +export sgzb_modules_file_jar=sgzb-modules-file.jar +export sgzb_modules_material_jar=sgzb-modules-material.jar export sgzb_auth_port=29200 export sgzb_gateway_port=28080 export sgzb_modules_system_port=29201 +export sgzb_modules_base_port=29301 +export sgzb_modules_file_port=9300 +export sgzb_modules_material_port=29302 if($auth_service_enable);then ## 启动authservice @@ -64,16 +76,15 @@ if($sgzb_gateway_enable);then echo "--------gateway 启动成功--------------" fi -if($sgzb-modules-system_enable);then - ## 启动system service - echo "--------modules system service 开始启动--------------" - echo "--------删除modules system service开始--------------" +if($sgzb_modules_system_enable);then + echo "--------sgzb_modules_system service 开始启动--------------" + echo "--------删除 sgzb_modules_system service开始--------------" P_ID=`ps -ef | grep -w $sgzb_modules_system_jar | grep -v "grep" | awk '{print $2}'` if [ "$P_ID" == "" ]; then - echo "===modules system service process not exists or stop success" + echo "===sgzb_modules_system service process not exists or stop success" else kill -9 $P_ID - echo "modules system service killed success" + echo "sgzb_modules_system service killed success" fi nohup /usr/lib/jvm/jdk1.8.0_381/bin/java -jar $sgzb_modules_system_jar >/dev/null 2>&1 & sgzb_modules_system_pid=`lsof -i:$sgzb_modules_system_port|grep "LISTEN"|awk '{print $2}'` @@ -81,7 +92,66 @@ if($sgzb-modules-system_enable);then do sgzb-modules-system_pid=`lsof -i:$sgzb_modules_system_port|grep "LISTEN"|awk '{print $2}'` done - echo "modules system service pid is $sgzb_modules_system_pid" - echo "--------modules system service 启动成功--------------" + echo "modules sgzb_modules_system pid is $sgzb_modules_system_pid" + echo "--------sgzb_modules_system service 启动成功--------------" fi +if($sgzb_modules_base_enable);then + echo "--------sgzb_modules_base service 开始启动--------------" + echo "--------删除 sgzb_modules_base service开始--------------" + P_ID=`ps -ef | grep -w $sgzb_modules_base_jar | grep -v "grep" | awk '{print $2}'` + if [ "$P_ID" == "" ]; then + echo "===sgzb_modules_base service process not exists or stop success" + else + kill -9 $P_ID + echo "sgzb_modules_base service killed success" + fi + nohup /usr/lib/jvm/jdk1.8.0_381/bin/java -jar $sgzb_modules_base_jar >/dev/null 2>&1 & + sgzb_modules_base_pid=`lsof -i:$sgzb_modules_base_port|grep "LISTEN"|awk '{print $2}'` + until [ -n "$sgzb_modules_base_pid" ] + do + sgzb-modules-system_pid=`lsof -i:$sgzb_modules_base_port|grep "LISTEN"|awk '{print $2}'` + done + echo "modules sgzb_modules_base pid is $sgzb_modules_base_pid" + echo "--------sgzb_modules_base service 启动成功--------------" +fi + +if($sgzb_modules_file_enable);then + echo "--------sgzb_modules_file service 开始启动--------------" + echo "--------删除 sgzb_modules_file service开始--------------" + P_ID=`ps -ef | grep -w $sgzb_modules_file_jar | grep -v "grep" | awk '{print $2}'` + if [ "$P_ID" == "" ]; then + echo "===sgzb_modules_file service process not exists or stop success" + else + kill -9 $P_ID + echo "sgzb_modules_file service killed success" + fi + nohup /usr/lib/jvm/jdk1.8.0_381/bin/java -jar $sgzb_modules_file_jar >/dev/null 2>&1 & + sgzb_modules_file_pid=`lsof -i:$sgzb_modules_file_port|grep "LISTEN"|awk '{print $2}'` + until [ -n "$sgzb_modules_file_pid" ] + do + sgzb-modules-system_pid=`lsof -i:$sgzb_modules_file_port|grep "LISTEN"|awk '{print $2}'` + done + echo "modules sgzb_modules_file pid is $sgzb_modules_file_pid" + echo "--------sgzb_modules_file service 启动成功--------------" +fi + +if($sgzb_modules_material_enable);then + echo "--------sgzb_modules_material service 开始启动--------------" + echo "--------删除 sgzb_modules_material service开始--------------" + P_ID=`ps -ef | grep -w $sgzb_modules_material_jar | grep -v "grep" | awk '{print $2}'` + if [ "$P_ID" == "" ]; then + echo "===sgzb_modules_material service process not exists or stop success" + else + kill -9 $P_ID + echo "sgzb_modules_material service killed success" + fi + nohup /usr/lib/jvm/jdk1.8.0_381/bin/java -jar $sgzb_modules_material_jar >/dev/null 2>&1 & + sgzb_modules_material_pid=`lsof -i:$sgzb_modules_material_port|grep "LISTEN"|awk '{print $2}'` + until [ -n "$sgzb_modules_material_pid" ] + do + sgzb-modules-system_pid=`lsof -i:$sgzb_modules_material_port|grep "LISTEN"|awk '{print $2}'` + done + echo "modules sgzb_modules_material pid is $sgzb_modules_material_pid" + echo "--------sgzb_modules_material service 启动成功--------------" +fi diff --git a/scripts/pipeline.sh b/scripts/pipeline.sh index 325d253b..50d138c0 100644 --- a/scripts/pipeline.sh +++ b/scripts/pipeline.sh @@ -9,7 +9,7 @@ pipeline { stages { stage('Check out') { steps { - withCredentials([usernamePassword(credentialsId: 'your-git-credentials', passwordVariable: 'Max@2023', usernameVariable: 'bonus')]) { + withCredentials([usernamePassword(credentialsId: 'f7070987-9b49-4ae1-af6d-53a3bf26799b', passwordVariable: 'Max@2023', usernameVariable: 'bonus')]) { checkout([ $class: 'GitSCM', branches: [[name: '*/dev-cq']], @@ -63,17 +63,17 @@ pipeline { sh '''BUILD_ID=DONTKILLME sh ${WORKSPACE}/scripts/deploy.sh''' } } -# stage('Dingding') { -# steps { -# echo 'Dingding start!' -# script { -# def webhookUrl = 'https://oapi.dingtalk.com/robot/send?access_token=eae0af98514a0db9a9a0d5cd8e337d13e7c16cd81d4a90b503e465a573020add' //替换为你自己的钉钉机器人Webhook地址 -# def message = "${JOB_NAME} TEST已完成: ${env.BUILD_URL} \n 到Sonarqube查看问题:http://192.168.0.56:9000/dashboard?id=${JOB_NAME} \n 查看新包: http://192.168.0.56/${JOB_NAME}/${BUILD_NUMBER} \n 现在访问测试站点: http://192.168.0.56:2911/bmw/index.html \n 用户名:ysExamAdmin 密码:Zys0825. " -# echo "${message}" -# sh "curl -H 'Content-Type: application/json' -d '{\"msgtype\": \"text\", \"text\": {\"content\": \"${message}\"}, \"at\": {\"atMobiles\": [\"张三,李四\"], \"isAtAll\": true}}' ${webhookUrl}" -# } -# } -# } + stage('Dingding') { + steps { + echo 'Dingding start!' + script { + def webhookUrl = 'https://oapi.dingtalk.com/robot/send?access_token=eae0af98514a0db9a9a0d5cd8e337d13e7c16cd81d4a90b503e465a573020add' //替换为你自己的钉钉机器人Webhook地址 + def message = "${JOB_NAME} TEST已完成: ${env.BUILD_URL} \n 到Sonarqube查看问题:http://192.168.0.56:9000/dashboard?id=${JOB_NAME} \n 查看新包: http://192.168.0.56/${JOB_NAME}/${BUILD_NUMBER} " + echo "${message}" + sh "curl -H 'Content-Type: application/json' -d '{\"msgtype\": \"text\", \"text\": {\"content\": \"${message}\"}, \"at\": {\"atMobiles\": [\"张三,李四\"], \"isAtAll\": true}}' ${webhookUrl}" + } + } + } } }