ChatingRoomProject/Jenkinsfile

36 lines
1.1 KiB
Groovy
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
stages {
stage('Checkout') {
steps {
git branch: 'master', url: 'http://8.138.13.251:3000/flyfox/ChatingRoomProject'
}
}
stage('Build Docker Image') {
steps {
sh '''
docker build --pull -t chatroom:latest .
'''
}
}
stage('Deploy to k3s') {
steps {
sh '''
# 删除旧的 Deployment 和 Service如果存在
kubectl --insecure-skip-tls-verify=true delete deployment chatroom-deployment --ignore-not-found=true
kubectl --insecure-skip-tls-verify=true delete service chatroom-deployment --ignore-not-found=true
# 部署新的 Deployment
kubectl --insecure-skip-tls-verify=true create deployment chatroom-deployment --image=chatroom:latest
# 暴露 Service
kubectl --insecure-skip-tls-verify=true expose deployment chatroom-deployment --type=NodePort --port=3030 --target-port=3030
'''
}
}
}
}