Provide a way to add extra arguements when building docker images 93/67393/5
authorStamatis Katsaounis <mokats@intracom-telecom.com>
Tue, 26 Mar 2019 09:23:54 +0000 (11:23 +0200)
committerStamatis Katsaounis <mokats@intracom-telecom.com>
Tue, 26 Mar 2019 14:33:03 +0000 (16:33 +0200)
This patch adds a parameter for extra arguements to be used to build
OPNFV docker images.

Change-Id: I65d5b96e5b0db348a4f200e6ef26b5b6ca65b348
Signed-off-by: Stamatis Katsaounis <mokats@intracom-telecom.com>
jjb/releng/opnfv-docker-arm.yaml
jjb/releng/opnfv-docker.sh
jjb/releng/opnfv-docker.yaml

index 7e87c5f..102069a 100644 (file)
@@ -44,6 +44,7 @@
     dockerdir: "docker"
     docker_repo_name: "opnfv/{project}_aarch64"
     arch_tag: ""
+    extra_build_args: ""
 
     # yamllint disable rule:key-duplicates
     dockerrepo:
           name: ARCH_TAG
           default: "{arch_tag}"
           description: "If set, this value will be added to the docker image tag"
+      - string:
+          name: EXTRA_BUILD_ARGS
+          default: "{extra_build_args}"
+          description: "Whitespace separated key=value pairs. If set, these args will be used to build docker image"
 
     properties:
       - throttle:
index e647641..174bb57 100644 (file)
@@ -130,12 +130,18 @@ if [[ -n "${ARCH_TAG}" ]]; then
     ARCH_BUILD_ARG="--build-arg ARCH=${ARCH_TAG}"
 fi
 
+EXTRA_BUILD_ARGS=${EXTRA_BUILD_ARGS:-}
+if [ -n "${EXTRA_BUILD_ARGS}" ]; then
+    EXTRA_BUILD_ARGS=" "$(echo ${EXTRA_BUILD_ARGS})
+    EXTRA_BUILD_ARGS=${EXTRA_BUILD_ARGS// / --build-arg }
+fi
+
 # Start the build
 echo "Building docker image: $DOCKER_REPO_NAME:$DOCKER_TAG"
 echo "--------------------------------------------------------"
 echo
 cmd="docker build --pull=true --no-cache -t $DOCKER_REPO_NAME:$DOCKER_TAG --build-arg BRANCH=$BUILD_BRANCH
-    $ARCH_BUILD_ARG
+    $ARCH_BUILD_ARG $EXTRA_BUILD_ARGS
     -f $DOCKERFILE $DOCKER_PATH"
 
 echo ${cmd}
index 591452a..446b305 100644 (file)
@@ -45,6 +45,7 @@
     dockerfile: "Dockerfile"
     dockerdir: "docker"
     arch_tag: ""
+    extra_build_args: ""
 
     # This is the dockerhub repo the image will be pushed to as
     # 'opnfv/{dockerrepo}. See: DOCKER_REPO_NAME parameter.
     dockerfile: "Dockerfile"
     dockerdir: "docker"
     arch_tag: ""
+    extra_build_args: ""
 
     project:
       # projects with jobs for master
           name: ARCH_TAG
           default: "{arch_tag}"
           description: "If set, this value will be added to the docker image tag as a prefix"
+      - string:
+          name: EXTRA_BUILD_ARGS
+          default: "{extra_build_args}"
+          description: "Whitespace separated key=value pairs. If set, these args will be used to build docker image"
 
     properties:
       - throttle: