Files
pipeline-scripts/oms_jenkins

65 lines
2.3 KiB
Plaintext
Raw Normal View History

2024-10-15 01:57:34 +00:00
pipeline {
agent any
tools {
nodejs 'nodejs'
}
stages {
stage('拉取代码') {
steps {
checkout([
$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
2024-10-15 02:09:29 +00:00
userRemoteConfigs: [[url: 'http://git.sinoecare.com/lab/dvcp-node-service.git',credentialsId:'b42f8b48-95a4-4039-ae51-b1dff06d943b']]
2024-10-15 01:57:34 +00:00
])
}
}
stage('打包') {
steps {
echo 'Building...'
2024-10-16 16:35:30 +08:00
sh 'docker build -t oms-node-service .'
2024-10-15 01:57:34 +00:00
}
}
stage('部署') {
steps {
echo 'Deploying...'
// 这里可以添加测试步骤
2024-10-16 16:35:30 +08:00
// 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)])
2024-10-15 01:57:34 +00:00
}
}
}
post{
success {
script{
echo 'Deployment finished successfully.'
def currentTime = new Date().format('yyyy-MM-dd HH:mm:ss', TimeZone.getTimeZone('Asia/Shanghai'))
sh """
2024-10-16 16:35:30 +08:00
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=5c25c37c-0b91-4d1d-95d3-98a2bb7055c7' \\
2024-10-15 01:57:34 +00:00
-H 'Content-Type: application/json' \\
-d '{
"msgtype": "markdown",
"markdown": {
"content": ">构建结果oms构建打包服务部署完成!\\n
>完成时间:${currentTime}\\n
2024-10-16 16:35:30 +08:00
>构建时间:${currentBuild.durationString}"
2024-10-15 01:57:34 +00:00
}
}'
"""
}
}
failure {
echo 'Deployment failed.'
}
}
}