Files
pipeline-scripts/oms_jenkins

66 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...'
sh 'npm i && npm run build'
}
}
stage('部署') {
steps {
echo 'Deploying...'
// 这里可以添加测试步骤
sh 'tar -zcvf dist.tar.gz -C dist .'
2024-10-15 02:19:44 +00:00
sshPublisher(publishers: [sshPublisherDesc(configName: 'dev87', transfers: [sshTransfer(
2024-10-15 01:57:34 +00:00
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.'
}
}
}