// 山田mster 后端备份
pipeline {
agent any
environment {
DINGDING_ROBOT_URL = 'https://oapi.dingtalk.com/robot/send?access_token=aa67b55f25245c319aedd6efe5d20d81ac1cfe6e858c15d20914e8fd26a4e6ac'
BRANCH= "shantian"
BUILD_USER_ID = ""
BUILD_USER = ""
BUILD_USER_EMAIL = ""
ChangeLog = ""
}
stages {
stage( 'checkout' ) {
steps {
checkout([$class: 'GitSCM' , branches: [[name: '*/shantian' ]], doGenerateSubmoduleConfigurations: false , extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'http://192.168.100.140/esl_backend/zk.git' ]]])
}
}
// 构建
stage( 'Build' ) {
steps {
withMaven(jdk: 'jdk' , maven: 'maven' ) {
sh 'mvn clean package -DskipTests'
}
}
}
// 同步jar包到服务器 start
stage( 'Push package' ) {
steps {
sshPublisher(publishers: [sshPublisherDesc(configName: '47.91.29.12' , transfers: [sshTransfer(cleanRemote: false , excludes: '' , execCommand: 'cd /usr/local/esl/ && docker-compose up -d --build' , execTimeout: 120000, flatten: false , makeEmptyDirs: false , noDefaultExcludes: false , patternSeparator: '[, ]+' , remoteDirectory: '/usr/local/esl/app' , remoteDirectorySDF: false , removePrefix: 'target' , sourceFiles: 'target/*' )], usePromotionTimestamp: false , useWorkspaceInPromotion: false , verbose: false )])
}
}
// 山田backup 01 start
stage( 'push package Backup 01' ) {
steps {
sshPublisher(publishers: [sshPublisherDesc(configName: '8.209.252.82' , transfers: [sshTransfer(cleanRemote: false , excludes: '' , execCommand: 'cd /usr/local/esl/ && docker-compose up -d --build' , execTimeout: 120000, flatten: false , makeEmptyDirs: false , noDefaultExcludes: false , patternSeparator: '[, ]+' , remoteDirectory: '/usr/local/esl/app' , remoteDirectorySDF: false , removePrefix: 'target' , sourceFiles: 'target/*' )], usePromotionTimestamp: false , useWorkspaceInPromotion: false , verbose: false )])
}
}
// 山田 backup 02 start
stage( 'Push package Backup 02' ) {
steps {
sshPublisher(publishers: [sshPublisherDesc(configName: '47.91.31.80' , transfers: [sshTransfer(cleanRemote: false , excludes: '' , execCommand: 'cd /usr/local/esl/ && docker-compose up -d --build' , execTimeout: 120000, flatten: false , makeEmptyDirs: false , noDefaultExcludes: false , patternSeparator: '[, ]+' , remoteDirectory: '/usr/local/esl/app' , remoteDirectorySDF: false , removePrefix: 'target' , sourceFiles: 'target/*' )], usePromotionTimestamp: false , useWorkspaceInPromotion: false , verbose: false )])
}
}
}
post {
// 构建失败通知
failure {
wrap([$class: 'BuildUser' ]) {
script {
BUILD_USER_ID = "${env.BUILD_USER_ID}"
BUILD_USER = "${env.BUILD_USER}"
BUILD_USER_EMAIL = "${env.BUILD_USER_EMAIL}"
ChangeLog = "${env.ChangeLog}"
}
}
script {
dingtalk (
robot: '31c097ba-4f71-4e9e-97f0-5f13e18c1ee2' ,
type : 'MARKDOWN' ,
title: "项目构建信息" ,
text: [
'### 项目构建信息' ,
">- job名称: **${JOB_NAME}**" ,
">- 持续时间: **${currentBuild.durationString}**" ,
">- 当前分支: **${env.BRANCH}**" ,
">- 构建发起: **${BUILD_USER}**" ,
">- 构建结果: **构建失败❌*" ,
">- 构建日志: [点击查看详情](${env.BUILD_URL}console)" ,
// ">- 更新记录: **${ChangeLog}**" ,
],
at: [
'所有人'
]
)
}
}
// 构建成功通知
success {
wrap([$class: 'BuildUser' ]) {
script {
BUILD_USER_ID = "${env.BUILD_USER_ID}"
BUILD_USER = "${env.BUILD_USER}"
BUILD_USER_EMAIL = "${env.BUILD_USER_EMAIL}"
ChangeLog = "${env.ChangeLog}"
}
}
dingtalk (
robot: '31c097ba-4f71-4e9e-97f0-5f13e18c1ee2' ,
type : 'MARKDOWN' ,
title: "项目构建信息" ,
text: [
'### 项目构建信息' ,
">- job名称: **${JOB_NAME}**" ,
">- 持续时间: **${currentBuild.durationString}**" ,
">- 当前分支: **${env.BRANCH}**" ,
">- 构建发起: **${BUILD_USER}**" ,
">- 构建结果: **构建成功 ✅**" ,
">- 构建日志: [点击查看详情](${env.BUILD_URL}console)" ,
// ">- 流水线: [点击查看详情](${env.JOB_URL}console)" ,
// ">- 更新记录: **${ChangeLog}**" ,
],
at: [
'所有人'
]
)
}
}
}
|