From 2cd087b58f0f5524b794eda8f4d5290cacb22ed1 Mon Sep 17 00:00:00 2001 From: "Lott, Christopher (cl778h)" Date: Wed, 31 Jul 2019 08:48:26 -0400 Subject: [PATCH] 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) --- jjb/com-log/com-log.yaml | 6 ++-- jjb/ric-plt-lib-rmr/ric-plt-lib-rmr.yaml | 4 +-- jjb/ric-plt-lib-rmr/shell/copy-rmr-packages.sh | 41 -------------------------- jjb/shell/export-packages.sh | 29 ++++++++++++++++++ 4 files changed, 35 insertions(+), 45 deletions(-) delete mode 100755 jjb/ric-plt-lib-rmr/shell/copy-rmr-packages.sh create mode 100755 jjb/shell/export-packages.sh diff --git a/jjb/com-log/com-log.yaml b/jjb/com-log/com-log.yaml index 80c72819..5465a473 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 d1f978a8..a27fb76c 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 c13c6207..00000000 --- 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 00000000..68957e9a --- /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" -- 2.16.6