From 45049de87b8f5b6c25680425387199725e61710f Mon Sep 17 00:00:00 2001 From: Marcus Noble Date: Tue, 24 Dec 2019 11:59:17 +0000 Subject: [PATCH] Restart deployment when new image built (#2) --- Jenkinsfile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 34af35b..d22f5a7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,7 +22,23 @@ pipeline { container('docker') { sh """ docker login docker.cloud.cluster.fun -u $DOCKER_CREDS_USR -p $DOCKER_CREDS_PSW + docker tag docker.cloud.cluster.fun/averagemarcus/blog:${env.GIT_COMMIT} docker.cloud.cluster.fun/averagemarcus/blog:latest docker push docker.cloud.cluster.fun/averagemarcus/blog:${env.GIT_COMMIT} + docker push docker.cloud.cluster.fun/averagemarcus/blog:latest + """ + } + } + } + + stage('Restart deployment') { + when { branch 'master' } + steps { + container('kubectl') { + sh """ + set +x + mkdir -p ~/.kube/ + printf "\$CLOUD_KUBECONFIG" > ~/.kube/config + kubectl --kubeconfig ~/.kube/config rollout restart deployment/blog --namespace default """ } }