Files
pipeline-scripts/oms_jenkins
2024-10-21 14:40:53 +08:00

60 lines
2.2 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 'docker stop oms-node-service || true && docker rm oms-node-service || true'
sh 'docker run -d --name oms-node-service -p 12525:12525 --restart=unless-stopped -v /home/deploy/node_deploy/base-wxcp:/base-wxcp -v /home/deploy/node_deploy/dvcp_v2_wechat:/dvcp_v2_wechat -v /home/deploy/node_deploy/zips:/zips -v /home/deploy/node_deploy/base-web:/base-web -v /usr/bin/zip:/usr/bin/zip --privileged oms-node-service:latest'
}
}
}
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": ">构建结果oms构建打包服务部署完成!\\n
>完成时间:${currentTime}\\n
>构建时间:${currentBuild.durationString}"
}
}'
"""
}
}
failure {
echo 'Deployment failed.'
}
}
}