aboutsummaryrefslogtreecommitdiffstats
path: root/jenkins-common.sh
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-11-18 16:45:28 +0100
committerlaforge <laforge@osmocom.org>2020-12-01 11:46:20 +0000
commit78ae9377a743db01c6d1b26daf563ef2f8f7eb6e (patch)
treebc20c5faa37763162cb0fc64260d69977f1e01f4 /jenkins-common.sh
parentb83c28fc34c3cabd8ea51bf9dd7a6981b1efd56a (diff)
common: Automatize UPSTREAM_DISTRO name based on image name
Similar to what is already done with DISTRO, which points to given image of ours based on name. This time we do the same with upstream images, such as debian:stretch or centos:centos8. This way, for instance calling docker_images_require "osmo-bsc-latest-centos8" would try to build the osmo-bsc-latest/Dockerfile file starting from a centos8 image. Change-Id: I33cb21aa024396974559fd98f9f3c64e2c351eda
Diffstat (limited to 'jenkins-common.sh')
-rw-r--r--jenkins-common.sh27
1 files changed, 21 insertions, 6 deletions
diff --git a/jenkins-common.sh b/jenkins-common.sh
index d9e79a4..fdcfd40 100644
--- a/jenkins-common.sh
+++ b/jenkins-common.sh
@@ -12,10 +12,18 @@ docker_depends() {
docker_distro_from_image_name() {
case "$1" in
- osmo-*-centos8) echo "centos8"; ;;
+ osmo-*-centos8) echo "centos8" ;;
+ centos8-*) echo "centos8" ;;
*) echo "debian-stretch" ;;
esac
+}
+docker_upstream_distro_from_image_name() {
+ case "$1" in
+ osmo-*-centos8) echo "centos:centos8"; ;;
+ centos8-*) echo "centos:centos8" ;;
+ *) echo "debian:stretch" ;;
+ esac
}
docker_dir_from_image_name() {
@@ -27,15 +35,20 @@ docker_dir_from_image_name() {
# Make sure required images are available and build them if necessary.
# $*: image names (e.g. "debian-stretch-build", "osmo-mgw-master", "osmo-mgw-master-centos8")
-# The images are automatically built from the Dockerfile of the subdir of the same name. If there is a
-# distribution name at the end of the image name (e.g. osmo-mgw-master-centos8), it gets removed from the subdir
-# where the Dockerfile is taken from (e.g. osmo-mgw-master/Dockerfile) and DISTRO is passed accordingly
-# (e.g. DISTRO=centos8). This allows one Dockerfile for multiple distributions, without duplicating configs for
-# each distribution. Dependencies listed in docker_depends() are built automatically too.
+# The images are automatically built from the Dockerfile of the subdir of
+# the same name. If there is a distribution name at the end of the image
+# name (e.g. osmo-mgw-master-centos8), it gets removed from the subdir
+# where the Dockerfile is taken from (e.g. osmo-mgw-master/Dockerfile)
+# and UPSTREAM_DISTRO and DISTRO are passed accordingly (e.g.
+# UPSTREAM_DISTRO=centos:centos8 DISTRO=centos8). This allows one
+# Dockerfile for multiple distributions, without duplicating configs for
+# each distribution. Dependencies listed in docker_depends() are built
+# automatically too.
docker_images_require() {
local i
local from_line
local pull_arg
+ local upstream_distro_arg
local distro_arg
local depends
local dir
@@ -49,6 +62,7 @@ docker_images_require() {
# Trigger image build (cache will be used when up-to-date)
if [ -z "$NO_DOCKER_IMAGE_BUILD" ]; then
+ upstream_distro_arg="$(docker_upstream_distro_from_image_name "$i")"
distro_arg="$(docker_distro_from_image_name "$i")"
dir="$(docker_dir_from_image_name "$i")"
@@ -62,6 +76,7 @@ docker_images_require() {
echo "Building image: $i (export NO_DOCKER_IMAGE_BUILD=1 to prevent this)"
make -C "../$dir" \
PULL="$pull_arg" \
+ UPSTREAM_DISTRO="$upstream_distro_arg" \
DISTRO="$distro_arg" \
IMAGE="$REPO_USER/$i" \
|| exit 1