You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1014 B
39 lines
1014 B
pipeline {
|
|
agent any
|
|
|
|
environment {
|
|
DOCKER_IMAGE = "my-web-app:latest"
|
|
K8S_DEPLOYMENT_NAME = "my-web-app-deployment"
|
|
}
|
|
|
|
stages {
|
|
stage('Build Docker Image') {
|
|
steps {
|
|
script {
|
|
docker.build("${DOCKER_IMAGE}")
|
|
}
|
|
}
|
|
}
|
|
stage('Push to Registry') {
|
|
steps {
|
|
script {
|
|
// 假设已经配置了 Docker 认证
|
|
docker.withRegistry('https://registry.example.com', 'registry-credentials') {
|
|
docker.image("${DOCKER_IMAGE}").push()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage('Deploy to Kubernetes') {
|
|
steps {
|
|
script {
|
|
kubernetesDeploy(
|
|
configs: 'k8s/deployment.yaml',
|
|
kubeconfigId: 'K8S_CLUSTER_CONFIG'
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|