Files
pipeline-scripts/web_jenkins
aixianling 2777fa5abe param(webhook): 将企微机器人 key 添加为可配置参数
- 在 Jenkins 构建参数中添加了 webhook 参数,默认值为之前的固定 key
- 修改了 curl 命令,使用 ${params.webhook} 替代硬编码的 key
2025-01-15 11:36:53 +08:00

67 lines
2.6 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
parameters {
string(name: 'pid', defaultValue: '', description: '定制方案的Id')
string(name: 'dist', defaultValue: '', description: '部署路径')
string(name: 'webhook', defaultValue: '1e734bc6-ab12-4272-8b15-cf92cb070f5b', description: '企微机器人key')
}
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_webapp.git',credentialsId:'b42f8b48-95a4-4039-ae51-b1dff06d943b']]
])
}
}
stage('打包') {
steps {
echo "正在打包的工程==>: ${params.pid}"
sh "npm i"
sh "node bin/build.js ${params.pid}&&npm run build"
}
}
stage('部署') {
steps {
echo 'Deploying...'
sh "tar -zcvf ${params.pid}.tar.gz -C dist ."
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=${params.webhook}' \\
-H 'Content-Type: application/json' \\
-d '{
"msgtype": "markdown",
"markdown": {
"content": ">构建结果web端打包完成!\\n
>完成时间:${currentTime}\\n
>构建时间:${currentBuild.durationString}"
}
}'
"""
}
}
failure {
echo 'Deployment failed.'
}
}
}