Add new file
This commit is contained in:
65
oms_jenkins
Normal file
65
oms_jenkins
Normal file
@@ -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.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user