<p>osmith has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/11365">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">jenkins-common.sh: add docker_images_require()<br><br>This new function can be used on top of each *-test/jenkins.sh to<br>specify which Docker images are required before the test can be<br>executed.<br><br>Unless the NO_DOCKER_IMAGE_BUILD environment variable is specified,<br>it will build all of these images. With the existing logic, this will<br>only rebuild images if they are outdated and otherwise use the cached<br>version (in that case it goes through almost instantly).<br><br>It also aborts if an image is missing, so we don't need to find that<br>out by reading through the log after running an entire build job.<br><br>The top-level Makefile should also be able to build all Docker images<br>on which a job depends. But it is not maintained anymore. And in that<br>Makefile the list of dependencies can not be specified dynamically,<br>as it will be necessary for OS#3268: ttcn3-mgw-test may depend on<br>osmo-mgw-latest or on osmo-mgw-master.<br><br>Related: OS#3268<br>Change-Id: I0afdf3400282634fca9b31d57eaeedd6b5c28aa1<br>---<br>M jenkins-common.sh<br>1 file changed, 19 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/docker-playground refs/changes/65/11365/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/jenkins-common.sh b/jenkins-common.sh</span><br><span>index 515479f..f3d6c61 100644</span><br><span>--- a/jenkins-common.sh</span><br><span>+++ b/jenkins-common.sh</span><br><span>@@ -1,3 +1,22 @@</span><br><span style="color: hsl(120, 100%, 40%);">+docker_image_exists() {</span><br><span style="color: hsl(120, 100%, 40%);">+        test -n "$(docker images -q "$REPO_USER/$1")"</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+docker_images_require() {</span><br><span style="color: hsl(120, 100%, 40%);">+     for i in $@; do</span><br><span style="color: hsl(120, 100%, 40%);">+               # Trigger image build (cache will be used when up-to-date)</span><br><span style="color: hsl(120, 100%, 40%);">+            if [ -z "$NO_DOCKER_IMAGE_BUILD" ]; then</span><br><span style="color: hsl(120, 100%, 40%);">+                    echo "Building image: $i (export NO_DOCKER_IMAGE_BUILD=1 to prevent this)"</span><br><span style="color: hsl(120, 100%, 40%);">+                  make -C "../$i"</span><br><span style="color: hsl(120, 100%, 40%);">+             fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+          # Detect missing images (build skipped/failure)</span><br><span style="color: hsl(120, 100%, 40%);">+               if ! docker_image_exists "$i"; then</span><br><span style="color: hsl(120, 100%, 40%);">+                 echo "ERROR: missing image: $i"</span><br><span style="color: hsl(120, 100%, 40%);">+                     exit 1</span><br><span style="color: hsl(120, 100%, 40%);">+                fi</span><br><span style="color: hsl(120, 100%, 40%);">+    done</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span> </span><br><span> network_create() {</span><br><span>    NET=$1</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/11365">change 11365</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/11365"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: docker-playground </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I0afdf3400282634fca9b31d57eaeedd6b5c28aa1 </div>
<div style="display:none"> Gerrit-Change-Number: 11365 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: osmith <osmith@sysmocom.de> </div>