2 # ============LICENSE_START=======================================================
3 # Copyright (C) 2020 The Nordix Foundation. All rights reserved.
4 # ================================================================================
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # SPDX-License-Identifier: Apache-2.0
18 # ============LICENSE_END=========================================================
24 # Make directory to hold docker image artifacts
25 mkdir -p $DOCKER_IMAGE_ARTIFACT_DIRECTORY
27 # Ensure at root of WORKSPACE
30 # For each docker image
31 for DOCKER_IMAGE in $(echo $DOCKER_IMAGES | tr "," "\n")
33 echo "----------------------------------------------------"
34 echo "Info: Archiving $DOCKER_IMAGE"
35 echo "----------------------------------------------------"
36 # Generate a name for the archive from its docker image name
37 # e.g. uds/sdc-customization/eo-cassandra-init becomes eo-cassandra-init
38 DOCKER_IMAGE_TAG=$(docker images $DOCKER_IMAGE | awk '{ print $2}' | sed -n '2p')
39 # Create docker tag for filename using uds build version e.g. 1.5-STAGING-latest
40 DOCKER_IMAGE_NAME=$(echo $DOCKER_IMAGE | awk -F/ '{print $NF}')
41 # Create docker tag for filename using timestamp e.g. 1.5.0-20200610T134812Z
42 #DOCKER_IMAGE_TAG=$(docker images $DOCKER_IMAGE | awk '{ print $2}' | sed -n '3p')
44 # Create the archive.tar.gz
45 # Naming convention <docker-image-name>-<tag>-<project-commit-ids>.tar.gz
46 # Includes SHA commit ids of the projects for traceability of the artifacts
47 # e.g. eo-cassandra-init-1.7-STAGING-latest-6d3abef-d96bad4.tar.gz
48 docker save $DOCKER_IMAGE | gzip -c > $DOCKER_IMAGE_ARTIFACT_DIRECTORY/$DOCKER_IMAGE_NAME-$DOCKER_IMAGE_TAG-$COMMIT_IDS.tar.gz