From aeca4ec56b4f142bc2ce82a2d08157ad155a6709 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Tue, 10 Mar 2020 16:52:55 +0800 Subject: [PATCH] modified: Jenkinsfile Added code to automatically deploy builds to k8s --- Jenkinsfile | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c17c8e9..8e2dc07 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,12 +6,22 @@ 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/nzbhydra2" - stage "build" - def app = docker.build "library/x86_64/alpine/nzbhydra2" - - 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 nzbhydra-0" + } + } + catch (err) { + currentBuild.result = 'FAILURE' + } } } +