Copy out DEB and RPM files, plain and dev 78/378/2
authorLott, Christopher (cl778h) <cl778h@att.com>
Tue, 18 Jun 2019 18:14:16 +0000 (14:14 -0400)
committerLott, Christopher (cl778h) <cl778h@att.com>
Tue, 18 Jun 2019 21:50:42 +0000 (17:50 -0400)
Using the new simple files: (list) format

Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
Change-Id: I8a2df39b4a967d08d6272a9dc430c87f3b40b707

jjb/ric-plt-lib-rmr/shell/copy-rmr-packages.sh

index 78caaea..c13c620 100755 (executable)
@@ -1,5 +1,6 @@
 #!/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
@@ -23,21 +24,18 @@ echo "--> copy-rmr-packages.sh"
 
 # extracts artifacts created by the builder
 # file with paths of generated deb, rpm packages
-pkgs="/tmp/build_output.yml"
+pkgs="build_packages.yml"
 
-# access builder files by creating a container with 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)
-docker cp "$container":"$pkgs" .
-pkgs_base=$(basename "$pkgs")
+docker cp "${container}:/tmp/${pkgs}" .
 
-# pip installs yq to $HOME/.local/bin
-deb=$(yq -r .deb "$pkgs_base")
-docker cp "$container":"$deb" .
-deb_base=$(basename "$deb")
-echo "Push file $deb_base" # TODO
-
-rpm=$(yq -r .rpm "$pkgs_base")
-docker cp "$container":"$rpm" .
-rpm_base=$(basename "$rpm")
-echo "Push file $rpm_base" # TODO
+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