69 lines
2.4 KiB
Plaintext
69 lines
2.4 KiB
Plaintext
pipeline {
|
|
agent any
|
|
tools {
|
|
maven 'mvn39'
|
|
jdk 'jdk18'
|
|
}
|
|
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 {
|
|
withEnv(['JAVA_HOME=/home/java/jdk_1.8.0']){
|
|
sh 'mvn clean package -Dmaven.test.skip=true'
|
|
}
|
|
}
|
|
}
|
|
stage('部署') {
|
|
steps {
|
|
script {
|
|
echo 'Deploying...'
|
|
def projectDir = '/home/product/product_breed/app'
|
|
def scriptPath = "/home/deploy/deploy_breed/run.sh"
|
|
sh "mv target/breed-service.jar ."
|
|
sshPublisher(publishers: [sshPublisherDesc(configName: 'test87', transfers: [sshTransfer(
|
|
sourceFiles: "breed-service.jar",
|
|
execCommand: "bash ${scriptPath}",
|
|
remoteDirectory: "${projectDir}")
|
|
], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: true)])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
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.'
|
|
}
|
|
}
|
|
}
|