From 27621fba185335fb4050c24ef2a373b0e7993347 Mon Sep 17 00:00:00 2001 From: Jonny Ervine Date: Mon, 2 Mar 2020 09:25:11 +0000 Subject: [PATCH] modified: Jenkinsfile Add code to automatically deploy to k8s --- Jenkinsfile | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c69c0f8..e226ba7 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/couchpotato" - stage "build" - def app = docker.build "library/x86_64/alpine/couchpotato" - - 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 cp-0 && kubectl -n media delete po cp-kids-0" + } + } + catch (err) { + currentBuild.result = 'FAILURE' + } } }