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

39 lines
982 B

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