I want to monitor a kubernetes pod created after redeploy task and once it is completed, I want to check the liquibase logs. If it is successful, I want to delete the job. How can I achieve this in gradle? I don't want to undeploy immediately after redeploy. So doLast is not an option. The following code doesn't keeps printing ob has not completed yet
task undeployAfterCompleted() {
group "kubernetes"
description "Undeploy the liquibase update job after completion"
def output = new ByteArrayOutputStream()
commandLine "bash", "-c", "kubectl get po -n pbr | grep 'liquibase' | awk '{ print \$3 }'"
while(!output.toString().equals('Completed')) {
sleep(5 * 1000)
println "Job has not completed yet."
commandLine "bash", "-c", "kubectl get po -n pbr | grep 'liquibase' | awk '{ print \$3 }'"
}
tasks.undeploy.execute()
}