|
|
|
@ -2,7 +2,8 @@ pipeline { |
|
|
|
|
agent any |
|
|
|
|
|
|
|
|
|
environment { |
|
|
|
|
docker_image = "my-web-app:latest" |
|
|
|
|
DOCKER_HOST = "tcp://192.168.75.149:2375" |
|
|
|
|
DOCKER_IMAGE = "my-web-app:latest" |
|
|
|
|
K8S_DEPLOYMENT_NAME = "my-web-app-deployment" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -11,7 +12,7 @@ pipeline { |
|
|
|
|
steps { |
|
|
|
|
script { |
|
|
|
|
try { |
|
|
|
|
docker.build("${docker_image}") |
|
|
|
|
docker.build("${DOCKER_IMAGE}") |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
// 处理构建错误 |
|
|
|
|
echo "构建镜像失败: ${e.message}" |
|
|
|
@ -26,7 +27,7 @@ pipeline { |
|
|
|
|
script { |
|
|
|
|
try { |
|
|
|
|
docker.withRegistry('http://core.harbor.cn', 'registry-credentials') { |
|
|
|
|
docker.image("${docker_image}").push() |
|
|
|
|
docker.image("${DOCKER_IMAGE}").push() |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
// 处理推送错误 |
|
|
|
|