From 1eade679b023e6d1c5f76bfde14696b84844ff47 Mon Sep 17 00:00:00 2001 From: sicmylife <37955758+sicmylife@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:08:10 +0200 Subject: [PATCH 1/2] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3ac7d57..e5a00be 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ pipeline { agent any environment { //be sure to replace "willbla" with your own Docker Hub username - DOCKER_IMAGE_NAME = "willbla/train-schedule" + DOCKER_IMAGE_NAME = "sicmylife/train-schedule" } stages { stage('Build') { @@ -76,4 +76,4 @@ pipeline { } } } -} \ No newline at end of file +} From 6e89cad375e3bb42635253f506f7abf1089c9735 Mon Sep 17 00:00:00 2001 From: sicmylife <37955758+sicmylife@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:21:24 +0200 Subject: [PATCH 2/2] Update Jenkinsfile --- Jenkinsfile | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e5a00be..489129d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,6 +3,7 @@ pipeline { environment { //be sure to replace "willbla" with your own Docker Hub username DOCKER_IMAGE_NAME = "sicmylife/train-schedule" + CANARY_REPLICAS = 0 } stages { stage('Build') { @@ -53,21 +54,29 @@ pipeline { ) } } - stage('DeployToProduction') { + stage('SmokeTest') { when { branch 'master' } - environment { - CANARY_REPLICAS = 0 + steps { + script { + sleep (time: 5) + def response = httpRequest ( + url: "http://$KUBE_MASTER_IP:8081/", + timeout: 30 + ) + if (response.status != 200) { + error("Smoke test against canary deployment failed.") + } + } + } + } + stage('DeployToProduction') { + when { + branch 'master' } steps { - input 'Deploy to Production?' milestone(1) - kubernetesDeploy( - kubeconfigId: 'kubeconfig', - configs: 'train-schedule-kube-canary.yml', - enableConfigSubstitution: true - ) kubernetesDeploy( kubeconfigId: 'kubeconfig', configs: 'train-schedule-kube.yml', @@ -76,4 +85,13 @@ pipeline { } } } + post { + cleanup { + kubernetesDeploy ( + kubeconfigId: 'kubeconfig', + configs: 'train-schedule-kube-canary.yml', + enableConfigSubstitution: true + ) + } + } }