Wait for gerrit to come up

Change-Id: I3c46f234276356406dd8b5040019a027911f9252
diff --git a/cicd-lab-pipeline.groovy b/cicd-lab-pipeline.groovy
index 3b3aefc..b979112 100644
--- a/cicd-lab-pipeline.groovy
+++ b/cicd-lab-pipeline.groovy
@@ -152,12 +152,25 @@
         }
 
         stage("Configure CI/CD services") {
+            // Aptly
             salt.enforceState(saltMaster, 'I@docker:swarm:role:master', 'aptly', true)
+
+            // Gerrit
+            timeout(600) {
+                println "Waiting for Gerrit to come up.."
+                salt.cmdRun(saltMaster, 'I@docker:swarm:role:master', 'while true; do curl -svf 172.16.10.254:8080 >/dev/null && break; done')
+            }
             retry(2) {
                 // Needs to run twice to pass __virtual__ method of gerrit module
                 // after installation of dependencies
                 salt.enforceState(saltMaster, 'I@docker:swarm:role:master', 'gerrit', true)
             }
+
+            // Jenkins
+            timeout(600) {
+                println "Waiting for Jenkins to come up.."
+                salt.cmdRun(saltMaster, 'I@docker:swarm:role:master', 'while true; do curl -svf 172.16.10.254:8081 >/dev/null && break; done')
+            }
             retry(2) {
                 // Same for jenkins
                 salt.enforceState(saltMaster, 'I@docker:swarm:role:master', 'jenkins', true)