commit 2ade397a6c77c8a0263580a16d2c2bb0a7a1beae Author: 艾贤凌 Date: Tue Oct 15 01:57:34 2024 +0000 Add new file diff --git a/oms_jenkins b/oms_jenkins new file mode 100644 index 0000000..1d6442c --- /dev/null +++ b/oms_jenkins @@ -0,0 +1,65 @@ +pipeline { + agent any + tools { + nodejs 'nodejs' + } + stages { + stage('拉取代码') { + steps { + checkout([ + $class: 'GitSCM', + branches: [[name: '*/master']], + doGenerateSubmoduleConfigurations: false, + extensions: [], + submoduleCfg: [], + userRemoteConfigs: [[url: 'http://git.sinoecare.com/lab/dvcp-node-service.git',credentialsId:'ec7d3c5e-3cb9-43a3-8134-05a734a13be4']] + ]) + } + } + stage('打包') { + steps { + echo 'Building...' + sh 'npm i && npm run build' + } + } + stage('部署') { + steps { + echo 'Deploying...' + // 这里可以添加测试步骤 + sh 'tar -zcvf dist.tar.gz -C dist .' + sshPublisher(publishers: [sshPublisherDesc(configName: 'oms构建打包服务', 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=bcabdfc6-e325-49bc-9442-5d3398c1d3ec' \\ + -H 'Content-Type: application/json' \\ + -d '{ + "msgtype": "markdown", + "markdown": { + "content": ">构建结果:oms构建打包服务部署完成!\\n + >完成时间:${currentTime}\\n + >构建时间:${currentBuild.durationString}" + + } + }' + """ + } + + } + failure { + echo 'Deployment failed.' + } + } +}