From 15d170490d3736dc56e2a7137aa907114ab48c70 Mon Sep 17 00:00:00 2001 From: aixianling Date: Thu, 31 Oct 2024 11:20:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0h5=E7=9A=84=E6=8C=81=E7=BB=AD?= =?UTF-8?q?=E9=9B=86=E6=88=90=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- h5_jenkins | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 h5_jenkins diff --git a/h5_jenkins b/h5_jenkins new file mode 100644 index 0000000..7ac7916 --- /dev/null +++ b/h5_jenkins @@ -0,0 +1,65 @@ +pipeline { + agent any + parameters { + string(name: 'pid', defaultValue: '', description: '定制方案的Id') + string(name: 'dist', defaultValue: '', description: '部署路径') + } + stages { + stage('拉取代码') { + steps { + checkout([ + $class: 'GitSCM', + branches: [[name: '*/h5-native']], + doGenerateSubmoduleConfigurations: false, + extensions: [], + submoduleCfg: [], + userRemoteConfigs: [[url: 'http://git.sinoecare.com/sinoecare/custom/base/base-wxcp.git',credentialsId:'b42f8b48-95a4-4039-ae51-b1dff06d943b']] + ]) + } + } + stage('打包') { + steps { + echo "正在打包的工程==>: ${params.pid}" + sh "npm i" + sh "node bin/build.js ${params.pid}&&npm run build" + } + } + stage('部署') { + steps { + echo 'Deploying...' + sh "tar -zcvf ${params.pid}.tar.gz -C dist/build/h5 ." + sshPublisher(publishers: [sshPublisherDesc(configName: 'dev87', transfers: [sshTransfer( + sourceFiles: "${params.pid}.tar.gz", + execCommand: "cd /home/deploy/node_deploy/zips&& ls -l|grep ${params.pid}&& tar -zxvf ${params.pid}.tar.gz -C ${params.dist} && rm -rf ${params.pid}.tar.gz", + remoteDirectory: 'zips') + ], 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": ">构建结果:H5打包完成!\\n + >完成时间:${currentTime}\\n + >构建时间:${currentBuild.durationString}" + } + }' + """ + } + + } + failure { + echo 'Deployment failed.' + } + } +}