fix: clean Jenkinsfile (single-quote sh blocks)

This commit is contained in:
xiangning 2026-07-03 17:37:02 +08:00
parent c25b91325e
commit d3330f6fc4

31
Jenkinsfile vendored
View File

@ -1,6 +1,5 @@
// BuildFlow buildflow-web CI/CD
// ①拉取代码 -> ②编译打包 -> 推送Harbor -> ③部署
// 飞书卡片通知(成功绿/失败红)
// BuildFlow buildflow-web CI/CD - clean version
// ①拉取代码 -> ②编译打包 -> 推送Harbor -> ③部署 + 飞书通知
def feishuNotify = { String result, String failedStageName = "" ->
def dur = currentBuild.durationString.replace(" and counting", "")
@ -28,8 +27,8 @@ def feishuNotify = { String result, String failedStageName = "" ->
def card = [msg_type: "interactive", card: [header: [title: [tag: "plain_text", content: title], template: color], elements: elements]]
def jsonStr = groovy.json.JsonOutput.toJson(card)
writeFile file: "/tmp/feishu_msg.json", text: jsonStr
sh "curl -sS -X POST https://open.feishu.cn/open-apis/bot/v2/hook/d215e8ed-edea-4f07-a77c-2a0e5b52d9b9 -H 'Content-Type: application/json' -d @/tmp/feishu_msg.json || true"
sh "rm -f /tmp/feishu_msg.json"
sh 'curl -sS -X POST https://open.feishu.cn/open-apis/bot/v2/hook/d215e8ed-edea-4f07-a77c-2a0e5b52d9b9 -H "Content-Type: application/json" -d @/tmp/feishu_msg.json || true'
sh 'rm -f /tmp/feishu_msg.json'
}
pipeline {
@ -59,12 +58,12 @@ pipeline {
stage("推送 Harbor") {
steps {
withCredentials([usernamePassword(credentialsId: "harbor-credentials", usernameVariable: "HUSER", passwordVariable: "HPASS")]) {
sh """
echo \$HPASS | docker login ${HARBOR} -u \$HUSER --password-stdin
docker push ${IMAGE}:${TAG}
docker push ${IMAGE}:latest
docker logout ${HARBOR}
"""
sh '''
echo $HPASS | docker login $HARBOR -u $HUSER --password-stdin
docker push $IMAGE:$TAG
docker push $IMAGE:latest
docker logout $HARBOR
'''
}
}
}
@ -73,11 +72,11 @@ pipeline {
script {
try {
node("deploy-agent") {
sh """
docker pull ${IMAGE}:latest
sh '''
docker pull $IMAGE:latest
docker rm -f buildflow-web 2>/dev/null || true
docker run -d --name buildflow-web --restart unless-stopped -p 5175:80 ${IMAGE}:latest
"""
docker run -d --name buildflow-web --restart unless-stopped -p 5175:80 $IMAGE:latest
'''
}
echo "部署完成"
} catch (e) {
@ -99,4 +98,4 @@ pipeline {
deleteDir()
}
}
}
}