Created
July 2, 2020 11:02
-
-
Save mabulgu/3972509bdf73f160a7aa5f6f25b705bd to your computer and use it in GitHub Desktop.
validate oc deployment
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
stage('Validate') { | |
openshift.withCluster(clusterName) { | |
openshift.withProject("${projectName}") { | |
def counter = 0 | |
def delay = 10 | |
def maxCounter = 1000 | |
println "Validating deployment of ${appName} in project ${projectName}" | |
def latestDCVersion = openshift.selector("dc","${appName}").object().status.latestVersion | |
def rcName = "${appName}-${latestDCVersion}" | |
while(counter++ <= maxCounter) { | |
def phase = openshift.selector("rc",rcName).object().metadata.annotations.get('openshift.io/deployment.phase') | |
if(phase == "Complete"){ | |
println "Deployment Succeeded!" | |
break | |
} else if(phase == "Cancelled"){ | |
error("Deployment Failed") | |
break | |
} else if(counter == maxCounter) { | |
error("Max Validation Attempts Exceeded. Failed Verifying Application Deployment...") | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment