From 4ee1b8e1393c6217b68b681502a96accc266e6a2 Mon Sep 17 00:00:00 2001 From: Jonny Ervine Date: Fri, 28 Feb 2020 09:18:17 +0000 Subject: [PATCH] modified: Jenkinsfile Added automatic k8s deployment --- Jenkinsfile | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c4f8f5e..dcbcd87 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,12 +6,21 @@ node("docker-node") { sh "git rev-parse HEAD > .git/commit-id" def commit_id = readFile('.git/commit-id').trim() println commit_id + + try { + stage "build" + def app = docker.build "library/x86_64/alpine/watcher" - stage "build" - def app = docker.build "library/x86_64/alpine/watcher" - - stage "publish" - app.push("${env.BUILD_NUMBER}") - app.push("latest") + stage "publish" + app.push("${env.BUILD_NUMBER}") + app.push("latest") + + stage('Deploy on k8s'){ + sh "/usr/local/bin/kubectl -n media delete po watcher-0" + } + } + catch (err) { + currentBuild.result = 'FAILURE' + } } }