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.
k8s-test/Jenkinsfile

40 lines
982 B

9 months ago
pipeline {
agent any
environment {
docker_image = "my-web-app:latest"
9 months ago
K8S_DEPLOYMENT_NAME = "my-web-app-deployment"
}
stages {
stage('构建镜像') {
9 months ago
steps {
script {
docker.build("${docker_image}")
9 months ago
}
}
}
stage('推送镜像') {
9 months ago
steps {
script {
// 假设已经配置了 Docker 认证
docker.withRegistry('http://core.harbor.cn', 'registry-credentials') {
docker.image("${docker_image}").push()
9 months ago
}
}
}
}
stage('部署k8s') {
9 months ago
steps {
script {
kubernetesDeploy(
configs: 'k8s/deploy.yaml',
9 months ago
kubeconfigId: 'K8S_CLUSTER_CONFIG'
)
}
}
}
}
}