aboutsummaryrefslogtreecommitdiffstats
path: root/jenkins-common.sh
diff options
context:
space:
mode:
authorOliver Smith <osmith@sysmocom.de>2020-05-30 08:27:21 +0200
committerOliver Smith <osmith@sysmocom.de>2020-05-30 09:14:41 +0200
commit3e3a29865551561a9e9eb4f24e2b89875c74e9e8 (patch)
treecc946ea88eca8f0a0204b3c083828f674f652a34 /jenkins-common.sh
parent2a628add9c6e4ad6999b443c9650a171a390490e (diff)
jenkins-common.sh: support osmo-*-centos8 images
Make it possible to call the ttcn3-*/jenkins.sh scripts with: IMAGE_SUFFIX="master-centos8" The existing docker_images_require lines of these jenkins.sh scripts will then call docker_images_require with arguments like "osmo-mgw-master-centos8". For example, from ttcn3-mgw-test/jenkins.sh: docker_images_require \ "osmo-mgw-$IMAGE_SUFFIX" \ "ttcn3-mgw-test" Let docker_images_require build the image from osmo-mgw-master/Dockerfile (-centos8 is cut off from the dirname) and with DISTRO=centos8 as argument. Collisions with the debian-stretch images are avoided by setting IMAGE to the full image name (e.g. osmo-mgw-master-centos8). Related: OS#4564 Change-Id: I598a262fe1a7ed4dd89e13c53e4ded103c6e3b91
Diffstat (limited to 'jenkins-common.sh')
-rw-r--r--jenkins-common.sh36
1 files changed, 34 insertions, 2 deletions
diff --git a/jenkins-common.sh b/jenkins-common.sh
index ea03d52..a29720c 100644
--- a/jenkins-common.sh
+++ b/jenkins-common.sh
@@ -4,16 +4,41 @@ docker_image_exists() {
docker_depends() {
case "$1" in
+ osmo-*-centos8) echo "centos8-build" ;;
osmo-*) echo "debian-stretch-build" ;;
ttcn3-*) echo "debian-stretch-titan" ;;
esac
}
+docker_distro_from_image_name() {
+ case "$1" in
+ osmo-*-centos8) echo "centos8"; ;;
+ *) echo "debian-stretch" ;;
+ esac
+
+}
+
+docker_dir_from_image_name() {
+ case "$1" in
+ osmo-*-centos8) echo "$1" | sed 's/\-centos8$//' ;;
+ *) echo "$1" ;;
+ esac
+}
+
+# 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.
docker_images_require() {
local i
local from_line
local pull_arg
+ local distro_arg
local depends
+ local dir
for i in $@; do
# Build dependencies first
@@ -24,15 +49,22 @@ docker_images_require() {
# Trigger image build (cache will be used when up-to-date)
if [ -z "$NO_DOCKER_IMAGE_BUILD" ]; then
+ distro_arg="$(docker_distro_from_image_name "$i")"
+ dir="$(docker_dir_from_image_name "$i")"
+
# Pull upstream base images
pull_arg="--pull"
- from_line="$(grep '^FROM' ../$i/Dockerfile)"
+ from_line="$(grep '^FROM' ../$dir/Dockerfile)"
if echo "$from_line" | grep -q '$USER'; then
pull_arg=""
fi
echo "Building image: $i (export NO_DOCKER_IMAGE_BUILD=1 to prevent this)"
- PULL="$pull_arg" make -C "../$i" || exit 1
+ make -C "../$dir" \
+ PULL="$pull_arg" \
+ DISTRO="$distro_arg" \
+ IMAGE="$REPO_USER/$i" \
+ || exit 1
fi
# Detect missing images (build skipped)