diff --git a/Jenkinsfile b/Jenkinsfile index 9651e38..67b8c5b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,5 @@ -// BuildFlow buildflow-portal CI/CD -// ①拉取代码 -> ②编译打包 -> 推送Harbor -> ③部署 -// 飞书卡片通知(成功绿/失败红) +// BuildFlow buildflow-portal 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-portal 2>/dev/null || true - docker run -d --name buildflow-portal --restart unless-stopped -p 5174:5173 ${IMAGE}:latest - """ + docker run -d --name buildflow-portal --restart unless-stopped -p 5174:5173 $IMAGE:latest + ''' } echo "部署完成" } catch (e) { @@ -99,4 +98,4 @@ pipeline { deleteDir() } } -} +} \ No newline at end of file