Added retry for problematic elaticsearch enforcement in cicd deploy pipeline

Change-Id: I6ce2deec22e78978cf3fbd2e5753c21f02ac13ca
diff --git a/cicd-lab-pipeline.groovy b/cicd-lab-pipeline.groovy
index 6f228fe..08279ba 100644
--- a/cicd-lab-pipeline.groovy
+++ b/cicd-lab-pipeline.groovy
@@ -227,6 +227,7 @@
                 println "Waiting for postgresql database to come up.."
                 salt.cmdRun(saltMaster, 'I@postgresql:client', 'while true; do if docker service logs postgresql_db | grep "ready to accept"; then break; else sleep 5; fi; done')
             }
+            // XXX: first run usually fails on some inserts, but we need to create databases at first 
             salt.enforceState(saltMaster, 'I@postgresql:client', 'postgresql.client', true, false)
 
             // Setup postgres database with integration between
@@ -249,7 +250,11 @@
                 println 'Waiting for Elasticsearch to come up..'
                 salt.cmdRun(saltMaster, 'I@elasticsearch:client', 'while true; do curl -sf 172.16.10.254:9200 >/dev/null && break; done')
             }
-            salt.enforceState(saltMaster, 'I@elasticsearch:client', 'elasticsearch.client', true)
+            retry(2){
+              sleep(5)
+              // XXX: first run sometimes fails on update indexes, so we need to wait
+              salt.enforceState(saltMaster, 'I@elasticsearch:client', 'elasticsearch.client', true)
+            }
         }
 
         stage("Finalize") {