c13c62077d2d579f1e215f5710429730027cae92
[ci-management.git] / jjb / ric-plt-lib-rmr / shell / copy-rmr-packages.sh
1 #!/bin/bash -l
2 # use login flag to get $HOME/.local/bin in PATH
3 # bcos pip installs yq to $HOME/.local/bin
4
5 #==================================================================================
6 #       Copyright (c) 2019 Nokia
7 #       Copyright (c) 2018-2019 AT&T Intellectual Property.
8 #
9 #   Licensed under the Apache License, Version 2.0 (the "License");
10 #   you may not use this file except in compliance with the License.
11 #   You may obtain a copy of the License at
12 #
13 #       http://www.apache.org/licenses/LICENSE-2.0
14 #
15 #   Unless required by applicable law or agreed to in writing, software
16 #   distributed under the License is distributed on an "AS IS" BASIS,
17 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 #   See the License for the specific language governing permissions and
19 #   limitations under the License.
20 #==================================================================================
21
22 set -eux -o pipefail
23 echo "--> copy-rmr-packages.sh"
24
25 # extracts artifacts created by the builder
26 # file with paths of generated deb, rpm packages
27 pkgs="build_packages.yml"
28
29 # access builder files within a container created by running a trivial command
30 # environment variables are injected in previous Jenkins steps
31 container=$(docker run -d "$CONTAINER_PUSH_REGISTRY"/"$DOCKER_NAME":"$DOCKER_IMAGE_TAG" ls)
32 docker cp "${container}:/tmp/${pkgs}" .
33
34 count=$(yq -r '.files | length' $pkgs)
35 # modern bash syntax is helpful
36 for (( i = 0; i < count; i++ )); do
37     file=$(yq -r ".files[$i]" "$pkgs")
38     docker cp "$container":"$file" .
39     base=$(basename "$file")
40     echo "Push file $base" # TODO
41 done