Skip to content

Instantly share code, notes, and snippets.

@mabulgu
Created July 2, 2020 11:02
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 mabulgu/3972509bdf73f160a7aa5f6f25b705bd to your computer and use it in GitHub Desktop.
Save mabulgu/3972509bdf73f160a7aa5f6f25b705bd to your computer and use it in GitHub Desktop.
validate oc deployment
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