Refactor package-export script for reuse
Simplifies and renames from copy-rmr-packages to export-packages
so the script can be reused by many projects, starting with mdclog.
Change-Id: If25ad3ac6f4bc7df99707cebba335e001b0b01fe
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
diff --git a/jjb/com-log/com-log.yaml b/jjb/com-log/com-log.yaml
index 80c7281..5465a47 100644
--- a/jjb/com-log/com-log.yaml
+++ b/jjb/com-log/com-log.yaml
@@ -34,8 +34,11 @@
container-tag-method: latest
# maven settings file has docker credentials
mvn-settings: com-log-settings
+ # copy packages to Jenkins filesystem
+ post_docker_build_script: !include-raw-escape:
+ - ../shell/export-packages.sh
jobs:
- # verify only; no merge bcos no image is pushed
+ # TODO: define a merge template to push package, not image
- gerrit-docker-verify
<<: *log_docker_common
@@ -44,6 +47,5 @@
project: com/log
project-name: com-log
build-node: centos7-builder-1c-1g
-
jobs:
- gerrit-info-yaml-verify
diff --git a/jjb/ric-plt-lib-rmr/ric-plt-lib-rmr.yaml b/jjb/ric-plt-lib-rmr/ric-plt-lib-rmr.yaml
index d1f978a..a27fb76 100644
--- a/jjb/ric-plt-lib-rmr/ric-plt-lib-rmr.yaml
+++ b/jjb/ric-plt-lib-rmr/ric-plt-lib-rmr.yaml
@@ -34,9 +34,9 @@
container-tag-method: latest
# maven settings file has docker credentials
mvn-settings: ric-plt-lib-rmr-settings
- # copy deb to Jenkins filesystem
+ # copy packages to Jenkins filesystem
post_docker_build_script: !include-raw-escape:
- - shell/copy-rmr-packages.sh
+ - ../shell/export-packages.sh
jobs:
# TODO: define a merge template to push package, not image
- gerrit-docker-verify
diff --git a/jjb/ric-plt-lib-rmr/shell/copy-rmr-packages.sh b/jjb/ric-plt-lib-rmr/shell/copy-rmr-packages.sh
deleted file mode 100755
index c13c620..0000000
--- a/jjb/ric-plt-lib-rmr/shell/copy-rmr-packages.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/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.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#==================================================================================
-
-set -eux -o pipefail
-echo "--> copy-rmr-packages.sh"
-
-# extracts artifacts created by the builder
-# file with paths of generated deb, rpm packages
-pkgs="build_packages.yml"
-
-# 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}:/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
diff --git a/jjb/shell/export-packages.sh b/jjb/shell/export-packages.sh
new file mode 100755
index 0000000..68957e9
--- /dev/null
+++ b/jjb/shell/export-packages.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+#==================================================================================
+# Copyright (c) 2019 AT&T Intellectual Property.
+# Copyright (c) 2019 Nokia
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#==================================================================================
+
+set -eux -o pipefail
+echo "--> export-packages.sh"
+
+# Launches the docker image, which has an entrypoint script
+# that copies artifacts created by the builder to a directory.
+# Environment variables are injected in previous Jenkins steps.
+HOST=/tmp/export
+GUEST=/export
+mkdir -p "$HOST"
+docker run -v "$HOST":"$GUEST" "$CONTAINER_PUSH_REGISTRY"/"$DOCKER_NAME":"$DOCKER_IMAGE_TAG" "$GUEST"
+ls "$HOST"