6e9e6c4ea3296da5ce7ea68145d3a1e3c3abdaba
[infra/cicd.git] / jjb / cloud-infra / scripts / oom-upload.sh
1 #!/bin/bash
2
3 # ============LICENSE_START=======================================================
4 #  Copyright (C) 2021 The Nordix Foundation. All rights reserved.
5 # ================================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #      http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 # SPDX-License-Identifier: Apache-2.0
19 # ============LICENSE_END=========================================================
20
21 set -o errexit
22 set -o pipefail
23
24 ONAP_UMBRELLA_CHART="${WORKSPACE}/build/onap-oom/kubernetes/dist/packages/onap-${ONAP_OOM_CHART_VERSION}.tgz"
25 IMAGES_LIST="${WORKSPACE}/images.txt"
26 export NORDIX_ARM_REPO="nordix-oom"
27 export ARTIFACT_ARM_FOLDER="oom"
28 export BUILD_IDENTIFIER="${ONAP_OOM_GIT_REVISION}"
29 export NORDIX_ARTIFACT_URL="${NORDIX_ARM_HTTPS_URL}/${NORDIX_ARM_REPO}/${ARTIFACT_ARM_FOLDER}/${BUILD_IDENTIFIER}"
30
31 echo "Info  : Pushing ONAP umbrella chart to Nordix Harbor"
32 ${HELM_BIN} push "${ONAP_UMBRELLA_CHART}" "${NORDIX_REGISTRY}"
33
34 export BUILD_ARTIFACTS="${IMAGES_LIST}"
35 echo "Info  : Uploading ${BUILD_ARTIFACTS} to Nordix ARM ${NORDIX_ARM_REPO} repository"
36 for BUILD_ARTIFACT in $BUILD_ARTIFACTS; do
37   echo "Info  : Generating checksums for $BUILD_ARTIFACT"
38   ARTIFACT_MD5SUM=$(md5sum "${BUILD_ARTIFACT}" | cut -d' ' -f1)
39   ARTIFACT_SHASUM=$(shasum "${BUILD_ARTIFACT}" | cut -d' ' -f1)
40   ARTIFACT_SHA256SUM=$(sha256sum "${BUILD_ARTIFACT}" | cut -d' ' -f1)
41
42   REMOTE_ARTIFACT=$(echo "${BUILD_ARTIFACT}" | sed 's/.*\///g')
43
44   echo "Info  : Uploading ${BUILD_ARTIFACT} to Nordix Artifactory"
45   curl -s -S \
46       -H "X-JFrog-Art-Api:${NORDIX_ARM_TOKEN}" \
47       -H "X-Checksum-MD5:${ARTIFACT_MD5SUM}" \
48       -H "X-Checksum-Sha1:${ARTIFACT_SHASUM}" \
49       -H "X-Checksum-Sha256:${ARTIFACT_SHA256SUM}" \
50       -T "${BUILD_ARTIFACT}" \
51       "${NORDIX_ARTIFACT_URL}/${REMOTE_ARTIFACT}"
52   echo "Info  : Artifact ${BUILD_ARTIFACT} is available on ${NORDIX_ARTIFACT_URL}/${REMOTE_ARTIFACT}"
53 done
54
55 echo "Done!"
56
57 # vim: set ts=2 sw=2 expandtab: