From f393f318e51726a329a0dd3990a8b69c140fabfe Mon Sep 17 00:00:00 2001 From: Siamak Sadeghianfar Date: Thu, 12 Oct 2017 11:42:15 +0200 Subject: [PATCH] updated bluegreen template --- openshift/coolstore-bluegreen-template.yaml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/openshift/coolstore-bluegreen-template.yaml b/openshift/coolstore-bluegreen-template.yaml index a7d585f..3089772 100644 --- a/openshift/coolstore-bluegreen-template.yaml +++ b/openshift/coolstore-bluegreen-template.yaml @@ -935,12 +935,22 @@ objects: def altTag = "green" stage('Deploy (Not Live)') { - sh "oc get route cart -o jsonpath='{ .spec.to.name }' > activeservice" - activeService = readFile('activeservice').trim() + sh "oc get route cart -o json > routejson" + def json = readJSON text: readFile('routejson').trim() + def activeService + if (json.spec.to.weight == 100) { + activeService = json.spec.to.name + } else { + for (backend in json.spec.alternateBackends) { + if (backend.weight == 100) { activeService = backend.name } + } + } + if (activeService == "cart-blue") { tag = "green" altTag = "blue" } + openshiftTag sourceStream: 'cart', sourceTag: 'latest', destinationStream: 'cart', destinationTag: "latest-${tag}" sleep 10 openshiftVerifyDeployment deploymentConfig: "cart-${tag}", replicaCount: '1', verifyReplicaCount: true