Change in docker-playground[master]: jenkins-common.sh: add docker_images_require()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

osmith gerrit-no-reply at lists.osmocom.org
Tue Oct 16 09:46:38 UTC 2018


osmith has uploaded this change for review. ( https://gerrit.osmocom.org/11365


Change subject: jenkins-common.sh: add docker_images_require()
......................................................................

jenkins-common.sh: add docker_images_require()

This new function can be used on top of each *-test/jenkins.sh to
specify which Docker images are required before the test can be
executed.

Unless the NO_DOCKER_IMAGE_BUILD environment variable is specified,
it will build all of these images. With the existing logic, this will
only rebuild images if they are outdated and otherwise use the cached
version (in that case it goes through almost instantly).

It also aborts if an image is missing, so we don't need to find that
out by reading through the log after running an entire build job.

The top-level Makefile should also be able to build all Docker images
on which a job depends. But it is not maintained anymore. And in that
Makefile the list of dependencies can not be specified dynamically,
as it will be necessary for OS#3268: ttcn3-mgw-test may depend on
osmo-mgw-latest or on osmo-mgw-master.

Related: OS#3268
Change-Id: I0afdf3400282634fca9b31d57eaeedd6b5c28aa1
---
M jenkins-common.sh
1 file changed, 19 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/docker-playground refs/changes/65/11365/1

diff --git a/jenkins-common.sh b/jenkins-common.sh
index 515479f..f3d6c61 100644
--- a/jenkins-common.sh
+++ b/jenkins-common.sh
@@ -1,3 +1,22 @@
+docker_image_exists() {
+	test -n "$(docker images -q "$REPO_USER/$1")"
+}
+
+docker_images_require() {
+	for i in $@; do
+		# Trigger image build (cache will be used when up-to-date)
+		if [ -z "$NO_DOCKER_IMAGE_BUILD" ]; then
+			echo "Building image: $i (export NO_DOCKER_IMAGE_BUILD=1 to prevent this)"
+			make -C "../$i"
+		fi
+
+		# Detect missing images (build skipped/failure)
+		if ! docker_image_exists "$i"; then
+			echo "ERROR: missing image: $i"
+			exit 1
+		fi
+	done
+}
 
 network_create() {
 	NET=$1

-- 
To view, visit https://gerrit.osmocom.org/11365
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0afdf3400282634fca9b31d57eaeedd6b5c28aa1
Gerrit-Change-Number: 11365
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181016/0dabc1ec/attachment.htm>


More information about the gerrit-log mailing list