Pull docker images on targets successively

Currently this change is implemented for CICD stack only,
later it can be extended for all other components if needed.

Depends-on: https://gerrit.mcp.mirantis.com/#/c/32868/

Change-Id: I0ec4f6cfb79b7d28f48323451374f33529573922
Related-bug: #PROD-25515 (PROD:25515)
diff --git a/src/com/mirantis/mk/Orchestrate.groovy b/src/com/mirantis/mk/Orchestrate.groovy
index 50f27ab..8259a5d 100644
--- a/src/com/mirantis/mk/Orchestrate.groovy
+++ b/src/com/mirantis/mk/Orchestrate.groovy
@@ -713,6 +713,13 @@
 
     // Temporary exclude cfg node from docker.client state (PROD-24934)
     def dockerClientExclude = !salt.getPillar(master, 'I@salt:master', 'docker:client:stack:jenkins').isEmpty() ? 'and not I@salt:master' : ''
+    // Pull images first if any
+    def listCIMinions = salt.getMinions(master, "ci* ${dockerClientExclude} ${extra_tgt}")
+    for (int i = 0; i < listCIMinions.size(); i++) {
+        if (!salt.getReturnValues(salt.getPillar(master, listCIMinions[i], 'docker:client:images')).isEmpty()) {
+            salt.enforceState([saltId: master, target: listCIMinions[i], state: 'docker.client.images', retries: 2])
+        }
+    }
     salt.enforceState([saltId: master, target: "I@docker:swarm:role:master and I@jenkins:client ${dockerClientExclude} ${extra_tgt}", state: 'docker.client', retries: 2])
 
     // API timeout in minutes