Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
add33f2740
29
Jenkinsfile
vendored
29
Jenkinsfile
vendored
@ -1,6 +1,5 @@
|
|||||||
// BuildFlow buildflow-api CI/CD
|
// BuildFlow buildflow-api CI/CD - clean version
|
||||||
// ①拉取代码 -> ②编译打包 -> 推送Harbor -> ③部署
|
// ①拉取代码 -> ②编译打包 -> 推送Harbor -> ③部署 + 飞书通知
|
||||||
// 飞书卡片通知(成功绿/失败红)
|
|
||||||
|
|
||||||
def feishuNotify = { String result, String failedStageName = "" ->
|
def feishuNotify = { String result, String failedStageName = "" ->
|
||||||
def dur = currentBuild.durationString.replace(" and counting", "")
|
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 card = [msg_type: "interactive", card: [header: [title: [tag: "plain_text", content: title], template: color], elements: elements]]
|
||||||
def jsonStr = groovy.json.JsonOutput.toJson(card)
|
def jsonStr = groovy.json.JsonOutput.toJson(card)
|
||||||
writeFile file: "/tmp/feishu_msg.json", text: jsonStr
|
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 '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 'rm -f /tmp/feishu_msg.json'
|
||||||
}
|
}
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
@ -59,12 +58,12 @@ pipeline {
|
|||||||
stage("推送 Harbor") {
|
stage("推送 Harbor") {
|
||||||
steps {
|
steps {
|
||||||
withCredentials([usernamePassword(credentialsId: "harbor-credentials", usernameVariable: "HUSER", passwordVariable: "HPASS")]) {
|
withCredentials([usernamePassword(credentialsId: "harbor-credentials", usernameVariable: "HUSER", passwordVariable: "HPASS")]) {
|
||||||
sh """
|
sh '''
|
||||||
echo \$HPASS | docker login ${HARBOR} -u \$HUSER --password-stdin
|
echo $HPASS | docker login $HARBOR -u $HUSER --password-stdin
|
||||||
docker push ${IMAGE}:${TAG}
|
docker push $IMAGE:$TAG
|
||||||
docker push ${IMAGE}:latest
|
docker push $IMAGE:latest
|
||||||
docker logout ${HARBOR}
|
docker logout $HARBOR
|
||||||
"""
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,11 +72,11 @@ pipeline {
|
|||||||
script {
|
script {
|
||||||
try {
|
try {
|
||||||
node("deploy-agent") {
|
node("deploy-agent") {
|
||||||
sh """
|
sh '''
|
||||||
docker pull ${IMAGE}:latest
|
docker pull $IMAGE:latest
|
||||||
docker rm -f buildflow-api 2>/dev/null || true
|
docker rm -f buildflow-api 2>/dev/null || true
|
||||||
docker run -d --name buildflow-api --restart unless-stopped -p 5667:5667 ${IMAGE}:latest
|
docker run -d --name buildflow-api --restart unless-stopped -p 5667:5667 $IMAGE:latest
|
||||||
"""
|
'''
|
||||||
}
|
}
|
||||||
echo "部署完成"
|
echo "部署完成"
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user