aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Smith <osmith@sysmocom.de>2018-10-16 10:52:14 +0200
committerosmith <osmith@sysmocom.de>2018-10-26 08:11:44 +0000
commita89aa7f8037592e88c0f4a05473f6182561ce9b5 (patch)
tree7506b7506a6db6f366346e4b3b3a7493b7bbe0ff
parent21831c4ef688b0ef13d16f57b9779d792f54b686 (diff)
jenkins-common.sh: add docker_images_require()
This new function can be used on top of each *-test/jenkins.sh to automatically build the required Docker images before starting a testsuite. The top-level Makefile should also be able to build all Docker images on which a job depends. But 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. This will be used by Idbb708ab16cb71bab5069127945b63388222369e. Related: OS#3268 Change-Id: I0afdf3400282634fca9b31d57eaeedd6b5c28aa1
-rw-r--r--jenkins-common.sh19
1 files changed, 19 insertions, 0 deletions
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