Compare commits

..

4 Commits

Author SHA1 Message Date
aixianling
3b9721b0b1 ci: 添加 Jenkins 部署管道
- 新增 Jenkins 配置文件 chuanqi_server_jenkins
- 定义简单的部署管道,包括部署阶段和事后处理- 部署步骤为进入指定目录并执行 git pull 操作
- 事后处理包括成功和失败情况下的消息输出
2024-12-13 15:31:12 +08:00
aixianling
bcfe679910 Update Jenkins pipeline to use devops branch and add merge stage 2024-10-31 14:32:41 +08:00
aixianling
59e02be537 增加h5的持续集成脚本 2024-10-31 12:07:25 +08:00
aixianling
15d170490d 增加h5的持续集成脚本 2024-10-31 11:20:04 +08:00
2 changed files with 92 additions and 0 deletions

19
chuanqi_server_jenkins Normal file
View File

@@ -0,0 +1,19 @@
pipeline {
agent any
stages {
stage('部署') {
steps {
echo 'Deploying...'
sh "cd /home/cq/data&&git pull"
}
}
}
post{
success {
echo 'Deployment finished successfully.'
}
failure {
echo 'Deployment failed.'
}
}
}

73
h5_jenkins Normal file
View File

@@ -0,0 +1,73 @@
pipeline {
agent any
parameters {
string(name: 'pid', defaultValue: '', description: '定制方案的Id')
string(name: 'dist', defaultValue: '', description: '部署路径')
}
stages {
stage('拉取代码') {
steps {
checkout([
$class: 'GitSCM',
branches: [[name: '*/devops']],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
userRemoteConfigs: [[url: 'http://git.sinoecare.com/sinoecare/digital_village_v2/dvcp_v2_wxcp_app.git',credentialsId:'b42f8b48-95a4-4039-ae51-b1dff06d943b']]
])
}
}
stage('合并'){
steps{
echo '代码合并...'
sh 'git config --global user.name "jenkins"'
sh 'git config --global user.email "aixianling@sinoecare.com"'
sh 'git merge origin/dev --no-ff'
}
}
stage('打包') {
steps {
echo "正在打包的工程==>: ${params.pid}"
sh "npm i"
sh "node bin/pages.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.'
}
}
}