Skip to content

Instantly share code, notes, and snippets.

@tqvarnst
Last active April 25, 2017 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tqvarnst/9d63a29c2ac84c39103a54728f4c24d2 to your computer and use it in GitHub Desktop.
Save tqvarnst/9d63a29c2ac84c39103a54728f4c24d2 to your computer and use it in GitHub Desktop.
node('maven') {
stage('Build App') {
git url: "https://github.com/modernize-legacy-apps/monolith.git"
sh "mvn clean package -Popenshift"
}
stage('Integration Test') {
sh "mvn verify"
}
stage('Build Image') {
sh "oc start-build cart --from-file=deployments/ROOT.war --follow"
}
stage('Deploy') {
openshiftDeploy depCfg: 'coolstore'
openshiftVerifyDeployment depCfg: 'coolstore', replicaCount: 1, verifyReplicaCount: true
}
stage('Component Test') {
sh "curl -s -X POST http://coolstore-dev.coolstore.svc.cluster.local:8080/services/catalog"
}
def tag="blue"
def altTag="green"
stage('Promote') {
sh "oc get route coolstore -n collstore -o jsonpath='{ .spec.to.name }' > activeservice"
activeService = readFile('activeservice').trim()
if (activeService == "coolstore-prod-blue") {
tag = "green"
altTag = "blue"
}
openshiftTag sourceStream: 'cart', sourceTag: 'latest', namespace: 'coolstore', destinationStream: 'coolstore', destinationTag: "coolstore-prod-${tag}", destinationNamespace: 'coolstore'
sleep 10
openshiftVerifyDeployment deploymentConfig: "coolstore-prod-${tag}", replicaCount: '1', verifyReplicaCount: true, namespace: 'prod'
}
stage('End-To-End Test') {
sh "curl -s -X POST http://coolstore-prod-${tag}.coolstore.svc.cluster.local:8080/services/catalog"
}
stage('Approve Go Live') {
timeout(time:15, unit:'MINUTES') {
input message:'Go Live in Prod?'
}
}
stage('Go Live') {
sh "oc set route-backends coolstore-prod coolstore-prod-${tag}=100 coolstore-prod-${altTag}=0 -n coolstore"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment