2025-09-17 08:38:41 +00:00
|
|
|
|
pipeline {
|
|
|
|
|
|
agent any
|
|
|
|
|
|
|
|
|
|
|
|
stages {
|
|
|
|
|
|
stage('Checkout') {
|
|
|
|
|
|
steps {
|
2025-09-17 12:47:33 +00:00
|
|
|
|
git branch: 'master', url: 'http://8.138.13.251:3000/flyfox/ChatingRoomProject'
|
2025-09-17 08:38:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
stage('Build Docker Image') {
|
|
|
|
|
|
steps {
|
2025-09-17 12:47:33 +00:00
|
|
|
|
sh '''
|
|
|
|
|
|
docker build --pull -t chatroom:latest .
|
|
|
|
|
|
'''
|
2025-09-17 08:38:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
stage('Deploy to k3s') {
|
|
|
|
|
|
steps {
|
|
|
|
|
|
sh '''
|
2025-09-17 12:47:33 +00:00
|
|
|
|
# 删除旧的 Deployment 和 Service(如果存在)
|
2025-09-17 12:38:01 +00:00
|
|
|
|
kubectl --insecure-skip-tls-verify=true delete deployment chatroom-deployment --ignore-not-found=true
|
2025-09-17 12:47:33 +00:00
|
|
|
|
kubectl --insecure-skip-tls-verify=true delete service chatroom-deployment --ignore-not-found=true
|
|
|
|
|
|
|
|
|
|
|
|
# 部署新的 Deployment
|
2025-09-17 12:38:01 +00:00
|
|
|
|
kubectl --insecure-skip-tls-verify=true create deployment chatroom-deployment --image=chatroom:latest
|
2025-09-17 12:47:33 +00:00
|
|
|
|
|
|
|
|
|
|
# 暴露 Service
|
2025-09-17 12:38:01 +00:00
|
|
|
|
kubectl --insecure-skip-tls-verify=true expose deployment chatroom-deployment --type=NodePort --port=3030 --target-port=3030
|
2025-09-17 08:38:41 +00:00
|
|
|
|
'''
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|