-#!/bin/bash
+#!/bin/bash -l
+# use login flag to get $HOME/.local/bin in PATH
+# bcos pip installs yq to $HOME/.local/bin
+
#==================================================================================
# Copyright (c) 2019 Nokia
# Copyright (c) 2018-2019 AT&T Intellectual Property.
set -eux -o pipefail
echo "--> copy-rmr-packages.sh"
-# extracts to host the artifacts created by the builder
-
-# This file is created by RMr library build process
-# with path(s) to the generated artifact(s)
-file="/tmp/rmr_deb_path"
+# extracts artifacts created by the builder
+# file with paths of generated deb, rpm packages
+pkgs="build_packages.yml"
-# create a container from the image by running a trivial command
+# access builder files within a container created by running a trivial command
# environment variables are injected in previous Jenkins steps
-container=$(docker run -d "$CONTAINER_PUSH_REGISTRY"/"$DOCKER_NAME":"$DOCKER_IMAGE_TAG" ls "$file")
-docker logs "$container"
-docker cp "$container:$file" .
-filebase=$(basename "$file")
-deb=$(cat "$filebase")
-docker cp "$container:$deb" .
+container=$(docker run -d "$CONTAINER_PUSH_REGISTRY"/"$DOCKER_NAME":"$DOCKER_IMAGE_TAG" ls)
+docker cp "${container}:/tmp/${pkgs}" .
+
+count=$(yq -r '.files | length' $pkgs)
+# modern bash syntax is helpful
+for (( i = 0; i < count; i++ )); do
+ file=$(yq -r ".files[$i]" "$pkgs")
+ docker cp "$container":"$file" .
+ base=$(basename "$file")
+ echo "Push file $base" # TODO
+done