deploy
This commit is contained in:
parent
c3c9240fda
commit
f0ec406f04
|
|
@ -0,0 +1,87 @@
|
|||
#!/bin/sh
|
||||
export deploy_path=/opt/builds/${JOB_NAME}/${BUILD_NUMBER}
|
||||
echo "--------moveFile start--------------"
|
||||
rm -rf $deploy_path
|
||||
mkdir -p $deploy_path
|
||||
cd $deploy_path
|
||||
rm -rf *.jar
|
||||
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
|
||||
chmod 777 *.jar
|
||||
echo "--------moveFile end--------------"
|
||||
export sgzb_auth_enable=true
|
||||
export sgzb_gateway_enable=true
|
||||
export sgzb_modules_system_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_auth_port=29200
|
||||
export sgzb_gateway_port=28080
|
||||
export sgzb_modules_system_port=29201
|
||||
|
||||
if($auth_service_enable);then
|
||||
## 启动authservice
|
||||
echo "--------auth开始启动--------------"
|
||||
echo "--------删除auth开始--------------"
|
||||
P_ID=`ps -ef | grep -w $sgzb_auth_jar | grep -v "grep" | awk '{print $2}'`
|
||||
if [ "$P_ID" == "" ]; then
|
||||
echo "===auth service process not exists or stop success"
|
||||
else
|
||||
kill -9 $P_ID
|
||||
echo "auth service killed success"
|
||||
fi
|
||||
nohup /usr/lib/jvm/jdk1.8.0_381/bin/java -jar $sgzb_auth_jar >/dev/null 2>&1 &
|
||||
sgzb_auth_pid=`lsof -i:$sgzb_auth_port|grep "LISTEN"|awk '{print $2}'`
|
||||
until [ -n "$auth_service_pid" ]
|
||||
do
|
||||
auth_service_pid=`lsof -i:$sgzb_auth_port|grep "LISTEN"|awk '{print $2}'`
|
||||
done
|
||||
echo "auth service pid is $sgzb_auth_pid"
|
||||
echo "--------auth_service 启动成功--------------"
|
||||
fi
|
||||
|
||||
if($sgzb_gateway_enable);then
|
||||
echo "--------gateway 开始启动--------------"
|
||||
echo "--------删除gateway开始--------------"
|
||||
P_ID=`ps -ef | grep -w $sgzb_gateway_jar | grep -v "grep" | awk '{print $2}'`
|
||||
if [ "$P_ID" == "" ]; then
|
||||
echo "===gateway process not exists or stop success"
|
||||
else
|
||||
kill -9 $P_ID
|
||||
echo "gateway killed success"
|
||||
fi
|
||||
nohup /usr/lib/jvm/jdk1.8.0_381/bin/java -jar $sgzb_gateway_jar >/dev/null 2>&1 &
|
||||
sgzb_gateway_pid=`lsof -i:$sgzb_gateway_port|grep "LISTEN"|awk '{print $2}'`
|
||||
until [ -n "$sgzb_gateway_pid" ]
|
||||
do
|
||||
sgzb_gateway_pid=`lsof -i:$sgzb_gateway_port|grep "LISTEN"|awk '{print $2}'`
|
||||
done
|
||||
echo "gateway pid is $sgzb_gateway_pid"
|
||||
echo "--------gateway 启动成功--------------"
|
||||
fi
|
||||
|
||||
if($sgzb-modules-system_enable);then
|
||||
## 启动system service
|
||||
echo "--------modules system service 开始启动--------------"
|
||||
echo "--------删除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"
|
||||
else
|
||||
kill -9 $P_ID
|
||||
echo "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}'`
|
||||
until [ -n "$sgzb_modules_system_pid" ]
|
||||
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 启动成功--------------"
|
||||
fi
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo "--------moveFile start--------------"
|
||||
#cp -rf ${WORKSPACE}/scripts/sonar-project.properties ${WORKSPACE}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
pipeline {
|
||||
agent any
|
||||
environment {
|
||||
// 设置自定义JDK路径,因为每个项目可能需要不同版本的jdk
|
||||
JAVA_HOME = '/usr/lib/jvm/jdk1.8.0_381'
|
||||
JOBNAME="${JOB_NAME}"
|
||||
JENKINS_NODE_COOKIE = "dontKillMe"
|
||||
}
|
||||
stages {
|
||||
stage('Check out') {
|
||||
steps {
|
||||
withCredentials([usernamePassword(credentialsId: 'your-git-credentials', passwordVariable: 'Max@2023', usernameVariable: 'bonus')]) {
|
||||
checkout([
|
||||
$class: 'GitSCM',
|
||||
branches: [[name: '*/dev-cq']],
|
||||
doGenerateSubmoduleConfigurations: false,
|
||||
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: '']],
|
||||
submoduleCfg: [],
|
||||
userRemoteConfigs: [[url: 'http://192.168.0.56:3000/bonus/devicesmgt.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.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}"
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue