123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- pipeline {
- agent any
- environment {
- BUILD_USER = ""
- REMOTE_PATH = "/mdata/cooleshow-test/jenkins"
- BUILD_FILE = "libs.tar.gz"
- ROBOT_ID = "a346e21b-706e-4881-8e3b-6c48d16d0c3b"
- SSH_AUTH = "WH-COOLESHOW-TEST"
- }
- stages {
-
- stage('build param') {
- steps {
- wrap([$class: 'BuildUser']) {
- script {
- BUILD_USER = "${env.BUILD_USER}"
- }
- }
- echo "${BUILD_USER}"
- }
- }
-
- stage('build job') {
- steps {
- // 构建项目
- sh 'mvn clean package'
- // 打包Jar包
- sh " \
- rm -rf ./libs && mkdir libs \
- && cp service.md \
- cooleshow-user/user-admin/target/user-admin.jar \
- audio-analysis/target/audio-analysis.jar \
- cooleshow-auth/auth-server/target/auth-server.jar \
- cooleshow-bbs/target/cooleshow-bbs.jar \
- cooleshow-user/user-classroom/target/user-classroom.jar \
- cooleshow-cms/target/cooleshow-cms.jar \
- cooleshow-gateway/gateway-web/target/gateway-web.jar \
- cooleshow-mall/mall-admin/target/mall-admin.jar \
- cooleshow-mall/mall-portal/target/mall-portal.jar \
- cooleshow-user/user-student/target/user-student.jar \
- cooleshow-task/target/cooleshow-task.jar \
- cooleshow-user/user-teacher/target/user-teacher.jar \
- cooleshow-user/user-website/target/user-website.jar \
- cooleshow-websocket/target/cooleshow-websocket.jar \
- libs/ \
- && tar -zcf ${BUILD_FILE} libs/ \
- "
- }
- }
- stage('deploy job') {
- steps {
- sshPublisher(publishers: [sshPublisherDesc(configName: "${SSH_AUTH}", transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: "cd ${REMOTE_PATH} && ./jenkins-server.sh > jenkins.log", execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: "${REMOTE_PATH}", remoteDirectorySDF: false, removePrefix: '', sourceFiles: '**/*.tar.gz')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
- }
- }
- stage('clean job') {
- steps {
- sh "rm -rf ./libs && rm -f ${BUILD_FILE}"
- }
- }
- }
- post {
- success {
- dingtalk (
- robot: "a346e21b-706e-4881-8e3b-6c48d16d0c3b",
- type:'ACTION_CARD',
- atAll: false,
- title: "构建成功:${env.JOB_NAME}",
- //messageUrl: 'xxxx',
- text: [
- "### [${env.JOB_NAME}](${env.JOB_URL}) ",
- '---',
- "- 任务:[${currentBuild.displayName}](${env.BUILD_URL})",
- '- 状态:<font color=#00CD00 >成功</font>',
- "- 持续时间:${currentBuild.durationString}".split("and counting")[0],
- "- 执行人:${BUILD_USER}",
- ]
- )
- }
- failure{
- dingtalk (
- robot: "a346e21b-706e-4881-8e3b-6c48d16d0c3b",
- type:'ACTION_CARD',
- atAll: false,
- title: "构建失败:${env.JOB_NAME}",
- //messageUrl: 'xxxx',
- text: [
- "### [${env.JOB_NAME}](${env.JOB_URL}) ",
- '---',
- "- 任务:[${currentBuild.displayName}](${env.BUILD_URL})",
- '- 状态:<font color=#EE0000 >失败</font>',
- "- 持续时间:${currentBuild.durationString}".split("and counting")[0],
- "- 执行人:${BUILD_USER}",
- ]
- )
- }
- }
- }
|