59 lines
2.0 KiB
Plaintext
59 lines
2.0 KiB
Plaintext
pipeline {
|
|
agent any
|
|
stages {
|
|
stage('拉取代码') {
|
|
steps {
|
|
checkout([
|
|
$class: 'GitSCM',
|
|
branches: [[name: '*/dev']],
|
|
doGenerateSubmoduleConfigurations: false,
|
|
extensions: [],
|
|
submoduleCfg: [],
|
|
userRemoteConfigs: [[url: 'http://git.sinoecare.com/sinoecare/breed_service.git',credentialsId:'b42f8b48-95a4-4039-ae51-b1dff06d943b']]
|
|
])
|
|
}
|
|
}
|
|
stage('构建打包') {
|
|
steps {
|
|
sh "mvn clean package -Dmaven.test.skip=true"
|
|
}
|
|
}
|
|
stage('部署') {
|
|
steps {
|
|
echo 'Deploying...'
|
|
def project_dir = "/home/product/product_breed/app"
|
|
def jar_name = "breed-service.jar"
|
|
sh "scp target/${jar_name} ${project_dir}"
|
|
sh "cd ${project_dir}"
|
|
sh "BUILD_ID=dontKillMe setsid java -jar -Xmx500M -Xms500M ${jar_name} --spring.profiles.active=dev --server.port=19998 >/dev/null 2>&1 &"
|
|
}
|
|
}
|
|
}
|
|
post{
|
|
success {
|
|
script{
|
|
echo 'Deployment finished successfully.'
|
|
|
|
def currentTime = new Date().format('yyyy-MM-dd HH:mm:ss', TimeZone.getTimeZone('Asia/Shanghai'))
|
|
|
|
sh """
|
|
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=1e734bc6-ab12-4272-8b15-cf92cb070f5b' \\
|
|
-H 'Content-Type: application/json' \\
|
|
-d '{
|
|
"msgtype": "markdown",
|
|
"markdown": {
|
|
"content": ">构建结果:农业项目后端构建完成!\\n
|
|
>完成时间:${currentTime}\\n
|
|
>构建时间:${currentBuild.durationString}"
|
|
}
|
|
}'
|
|
"""
|
|
}
|
|
|
|
}
|
|
failure {
|
|
echo 'Deployment failed.'
|
|
}
|
|
}
|
|
}
|