pipeline { agent any tools { nodejs 'nodejs' } stages { stage('拉取代码') { steps { checkout([ $class: 'GitSCM', branches: [[name: '*/dev']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'http://git.sinoecare.com/lab/dvcp-node-service.git',credentialsId:'b42f8b48-95a4-4039-ae51-b1dff06d943b']] ]) } } stage('打包') { steps { echo 'Building...' sh 'docker build -t oms-node-service .' } } stage('部署') { steps { echo 'Deploying...' // 这里可以添加测试步骤 // sh 'tar -zcvf dist.tar.gz -C dist .' // sshPublisher(publishers: [sshPublisherDesc(configName: 'dev87', transfers: [sshTransfer( // sourceFiles: 'dist.tar.gz', // execCommand: 'cd /mnt/sdc/web/ && ls -a && tar -zxvf dist.tar.gz -C dist && rm -rf dist.tar.gz', // remoteDirectory: 'web') // ], 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=5c25c37c-0b91-4d1d-95d3-98a2bb7055c7' \\ -H 'Content-Type: application/json' \\ -d '{ "msgtype": "markdown", "markdown": { "content": ">构建结果:oms构建打包服务部署完成!\\n >完成时间:${currentTime}\\n >构建时间:${currentBuild.durationString}" } }' """ } } failure { echo 'Deployment failed.' } } }