add scripts

This commit is contained in:
sxu 2024-10-14 15:21:31 +08:00 committed by jjLv
parent dacd5656d4
commit e14ae7fe83
26 changed files with 467 additions and 0 deletions

View File

@ -0,0 +1,35 @@
# Tomcat
server:
port: 18581
# Spring
spring:
application:
# 应用名称
name: bonus-auth
profiles:
# 环境配置
active: sgzb_bns_test
cloud:
nacos:
username: nacos
password: bonus@Admin123
discovery:
# 服务注册地址
server-addr: 192.168.0.244:8848
namespace: sgzb_bns
config:
# 配置中心地址
server-addr: 192.168.0.244:8848
namespace: sgzb_bns
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
#加密组件
jasypt:
encryptor:
password: Encrypt

View File

@ -0,0 +1,29 @@
# Tomcat
server:
port: 18583
# Spring
spring:
application:
# 应用名称
name: bonus-file
profiles:
# 环境配置
active: sgzb_bns_test
cloud:
nacos:
username: nacos
password: bonus@Admin123
discovery:
# 服务注册地址
server-addr: 192.168.0.244:8848
namespace: sgzb_bns
config:
# 配置中心地址
server-addr: 192.168.0.244:8848
namespace: sgzb_bns
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

View File

@ -0,0 +1,58 @@
# Tomcat
server:
port: 18580
servlet:
context-path: zhgd
# Spring
spring:
application:
# 应用名称
name: bonus-gateway
profiles:
# 环境配置
active: sgzb_bns_test
cloud:
nacos:
username: nacos
password: bonus@Admin123
discovery:
# 服务注册地址
server-addr: 192.168.0.244:8848
namespace: sgzb_bns
config:
# 配置中心地址
server-addr: 192.168.0.244:8848
namespace: sgzb_bns
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
sentinel:
# 取消控制台懒加载
eager: true
transport:
# 控制台地址
dashboard: 192.168.0.14:18858
# nacos配置持久化
datasource:
ds1:
nacos:
username: nacos
password: bonus@Admin123
server-addr: 192.168.0.244:8848
namespace: sgzb_bns
dataId: sentinel-bonus-gateway
groupId: DEFAULT_GROUP
data-type: json
rule-type: gw-flow
#系统 自动 加解密开关
system:
encryptEnabled: false
decryptEnabled: true
#加密组件
jasypt:
encryptor:
password: Encrypt

View File

@ -0,0 +1,29 @@
# Tomcat
server:
port: 18584
# Spring
spring:
application:
# 应用名称
name: bonus-gen
profiles:
# 环境配置
active: sgzb_bns_test
cloud:
nacos:
username: nacos
password: bonus@Admin123
discovery:
# 服务注册地址
server-addr: 192.168.0.244:8848
namespace: sgzb_bns
config:
# 配置中心地址
server-addr: 192.168.0.244:8848
namespace: sgzb_bns
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

View File

@ -0,0 +1,29 @@
# Tomcat
server:
port: 18585
# Spring
spring:
application:
# 应用名称
name: bonus-job
profiles:
# 环境配置
active: sgzb_bns_test
cloud:
nacos:
username: nacos
password: bonus@Admin123
discovery:
# 服务注册地址
server-addr: 192.168.0.244:8848
namespace: sgzb_bns
config:
# 配置中心地址
server-addr: 192.168.0.244:8848
namespace: sgzb_bns
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

View File

@ -0,0 +1,35 @@
# Tomcat
server:
port: 18588
# Spring
spring:
servlet:
multipart:
# 文件最大
max-file-size: 20MB
# 设置总上传数据总大小
max-request-size: 20MB
application:
# 应用名称
name: bonus-material
profiles:
# 环境配置
active: sgzb_bns_test
cloud:
nacos:
username: nacos
password: bonus@Admin123
discovery:
# 服务注册地址
server-addr: 192.168.0.244:8848
namespace: sgzb_bns
config:
# 配置中心地址
server-addr: 192.168.0.244:8848
namespace: sgzb_bns
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

80
scripts_244/pipeline.sh Normal file
View File

@ -0,0 +1,80 @@
pipeline {
agent any
environment {
// 设置自定义JDK路径因为每个项目可能需要不同版本的jdk
JAVA_HOME = '/usr/lib/jvm/jdk1.8.0_381'
JOBNAME="${JOB_NAME}"
JENKINS_NODE_COOKIE = "dontKillMe"
#SPRING_PROFILES_ACTIVE = "dev"
}
stages {
stage('Check out') {
steps {
withCredentials([usernamePassword(credentialsId: 'f7070987-9b49-4ae1-af6d-53a3bf26799b', passwordVariable: 'Max@2023', usernameVariable: 'bonus')]) {
checkout([
$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: '']],
submoduleCfg: [],
userRemoteConfigs: [[url: 'http://192.168.0.244:3000/bonus/Bonus-Cloud-Material.git']]
])
}
}
}
stage('Move file') {
steps {
echo 'move file start!'
sh 'chmod 777 ${WORKSPACE}/scripts/*'
// 如果需要拷贝文件,打开并编写以下脚本
// sh '${WORKSPACE}/scripts/moveFile.sh'
}
}
stage('Build') {
steps {
echo 'build start!'
sh 'env JAVA_HOME=$JAVA_HOME /usr/local/src/apache-maven-3.9.4/bin/mvn clean package'
}
}
stage('Sonar scan') {
steps {
script {
echo 'sonar scan start!'
def scannerHome = tool 'sonar-scanner'
withSonarQubeEnv('sonarqube-server') {
sh "/usr/local/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner " +
"-Dsonar.projectKey=${JOB_NAME} " +
"-Dsonar.projectName=${JOB_NAME} " +
"-Dsonar.sourceEncoding=UTF-8 " +
"-Dsonar.language=java " +
"-Dsonar.projectVersion=1.0 " +
"-Dsonar.sources=. " +
"-Dsonar.java.source=1.8 " +
"-Dsonar.java.target=1.8 " +
"-Dsonar.scm.disabled=true " +
"-Dsonar.exclusions=test/**,node_modules/**,static/**,**/*.js,**/*.html,**/*.css,**/*.jar " +
"-Dsonar.java.binaries=**/target/classes"
}
}
}
}
stage('Deploy') {
steps {
echo 'deploy start!'
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.244:9000/dashboard?id=${JOB_NAME} \n 查看新包: http://192.168.0.244/${JOB_NAME}/${BUILD_NUMBER} "
echo "${message}"
sh "curl -H 'Content-Type: application/json' -d '{\"msgtype\": \"text\", \"text\": {\"content\": \"${message}\"}, \"at\": {\"atMobiles\": [\"张三,李四\"], \"isAtAll\": true}}' ${webhookUrl}"
}
}
}
}
}

View File

@ -0,0 +1,33 @@
# Tomcat
server:
port: 18582
# Spring
spring:
application:
# 应用名称
name: bonus-system
profiles:
# 环境配置
active: sgzb_bns_test
cloud:
nacos:
username: nacos
password: bonus@Admin123
discovery:
# 服务注册地址
server-addr: 192.168.0.244:8848
namespace: sgzb_bns
config:
# 配置中心地址
server-addr: 192.168.0.244:8848
namespace: sgzb_bns
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
system:
supports:
phoneLogin: true
emailLogin: true

View File

@ -0,0 +1,29 @@
# Tomcat
server:
port: 18586
# Spring
spring:
application:
# 应用名称
name: bonus-monitor
profiles:
# 环境配置
active: sgzb_bns_test
cloud:
nacos:
username: nacos
password: bonus@Admin123
discovery:
# 服务注册地址
server-addr: 192.168.0.244:8848
namespace: sgzb_bns
config:
# 配置中心地址
server-addr: 192.168.0.244:8848
namespace: sgzb_bns
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

37
scripts_56/deploy.sh.bk Normal file
View File

@ -0,0 +1,37 @@
#!/bin/sh
export deploy_path=/opt/builds/${JOB_NAME}
echo "--------moveFile start--------------"
rm -rf $deploy_path
mkdir -p $deploy_path
cd $deploy_path
rm -rf *.jar
echo "workspace is ${WORKSPACE}"
mv ${WORKSPACE}/bonus-modules/bonus-material/target/bonus-material.jar $deploy_path
chmod 777 *.jar
echo "--------moveFile end--------------"
export bonus_material_enable=true
export bonus_material_jar=bonus-material.jar
export bonus_material_port=18588
if($bonus_material_enable);then
echo "--------bonus_material 开始启动--------------"
echo "--------删除bonus__material开始--------------"
P_ID=`ps -ef | grep -w $bonus_material_jar | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===bonus_material process not exists or stop success"
else
kill -9 $P_ID
echo "bonus_material killed success"
fi
echo "--------bonus_material开始部署--------------"
nohup /usr/lib/jvm/jdk1.8.0_381/bin/java -jar $bonus_material_jar >/dev/null 2>&1 &
bonus_material_pid=`lsof -i:$bonus_material_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$bonus_material_pid" ]
do
bonus_material_pid=`lsof -i:$bonus_material_port|grep "LISTEN"|awk '{print $2}'`
done
echo "bonus_material pid is $bonus_material_pid"
echo "--------bonus_material 启动成功--------------"
fi

66
scripts_56/kill-ps.sh Normal file
View File

@ -0,0 +1,66 @@
AUTH_RESOURCE_NAME=bonus-auth.jar
tpid=`ps -ef|grep $AUTH_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -15 $tpid
fi
sleep 5
tpid=`ps -ef|grep $AUTH_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi
GATEWAY_RESOURCE_NAME=bonus-gateway.jar
tpid=`ps -ef|grep $GATEWAY_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -15 $tpid
fi
sleep 5
tpid=`ps -ef|grep $GATEWAY_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi
MA_RESOURCE_NAME=bonus-material.jar
tpid=`ps -ef|grep $MA_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -15 $tpid
fi
sleep 5
tpid=`ps -ef|grep $MA_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi
SYS_RESOURCE_NAME=bonus-system.jar
tpid=`ps -ef|grep $SYS_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -15 $tpid
fi
sleep 5
tpid=`ps -ef|grep $SYS_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi

View File

@ -0,0 +1,7 @@
P_ID=$(pgrep -f BonusMaterialApplication)
if [ -z "$P_ID" ]; then
echo "BonusMaterialApplication is not running"
else
kill -9 "$P_ID"
fi