Last active
September 2, 2019 03:33
-
-
Save giang-pham/b124fe0b200f6df9464f070d10c56bf5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
agent any | |
stages { | |
stage("Deploy") { | |
steps { | |
withKubeConfig([credentialsId: '[CREDENTIAL_ID]', serverUrl: '[AUTHENTICATION_SERVER]']) { | |
script { | |
active = sh(returnStdout: true, script: "kubectl get vs [VIRTUAL_SERVICE] -o yaml | grep -B1 'weight: 100' | pcregrep -o1 'subset: (.*)'").trim() | |
echo "active: $active" | |
if (active == "blue") { | |
env.SUBSET = "green" | |
} else { | |
env.SUBSET = "blue" | |
} | |
echo "subset: ${env.SUBSET}" | |
echo "version: ${env.NEW_VERSION}" | |
sh(returnStdout: true, script: "SUBSET=${env.SUBSET} NEW_VERSION=${env.NEW_VERSION} envsubst < [DEPLOY_YAML_DIR]") | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment