diff --git a/Jenkinsfile b/Jenkinsfile index 3ac7d5747..b64e8d336 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,8 @@ pipeline { agent any environment { //be sure to replace "willbla" with your own Docker Hub username - DOCKER_IMAGE_NAME = "willbla/train-schedule" + DOCKER_IMAGE_NAME = "mukeshmossy19/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 { } } } -} \ No newline at end of file + post { + cleanup { + kubernetesDeploy ( + kubeconfigId: 'kubeconfig', + configs: 'train-schedule-kube-canary.yml', + enableConfigSubstitution: true + ) + } + } +} diff --git a/train-schedule-kube-canary.yml b/train-schedule-kube-canary.yml index 9922ce94b..697f891e8 100644 --- a/train-schedule-kube-canary.yml +++ b/train-schedule-kube-canary.yml @@ -14,7 +14,7 @@ spec: --- -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: train-schedule-deployment-canary diff --git a/train-schedule-kube.yml b/train-schedule-kube.yml index 0222f1bc1..539f8e28f 100644 --- a/train-schedule-kube.yml +++ b/train-schedule-kube.yml @@ -13,7 +13,7 @@ spec: --- -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: train-schedule-deployment