ce3afb3b216350f13f15d1f0cc1c96caaa226a0c
[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-*.tgz"
25 HELM_BIN="${WORKSPACE}/bin/helm"
26 IMAGES_LIST="${WORKSPACE}/images.txt"
27 ONAP_OOM_GIT_REVISION=$(cd "${WORKSPACE}/build/onap-oom" && git rev-parse --short HEAD)
28 export NORDIX_ARM_REPO="nordix-oom"
29 export ARTIFACT_ARM_FOLDER="oom"
30 export BUILD_IDENTIFIER="${ONAP_OOM_GIT_REVISION}"
31 export NORDIX_ARTIFACT_URL="${NORDIX_ARM_HTTPS_URL}/${NORDIX_ARM_REPO}/${ARTIFACT_ARM_FOLDER}/${BUILD_IDENTIFIER}"
32
33 # NOTE(cian): Leaving this commented out for the moment.
34 #echo "Info  : Pushing ONAP umbrella chart to Nordix Harbor"
35 #${HELM_BIN} push "${ONAP_UMBRELLA_CHART}" "${NORDIX_REGISTRY}"
36
37 export BUILD_ARTIFACTS="${ONAP_UMBRELLA_CHART} ${IMAGES_LIST}"
38 echo "Info  : Uploading ${BUILD_ARTIFACTS} to Nordix ARM ${NORDIX_ARM_REPO} repository"
39 for BUILD_ARTIFACT in $BUILD_ARTIFACTS; do
40   echo "Info  : Generating checksums for $BUILD_ARTIFACT"
41   ARTIFACT_MD5SUM=$(md5sum "${BUILD_ARTIFACT}" | cut -d' ' -f1)
42   ARTIFACT_SHASUM=$(shasum "${BUILD_ARTIFACT}" | cut -d' ' -f1)
43   ARTIFACT_SHA256SUM=$(sha256sum "${BUILD_ARTIFACT}" | cut -d' ' -f1)
44
45   REMOTE_ARTIFACT=$(basename "${BUILD_ARTIFACT}")
46
47   echo "Info  : Uploading ${BUILD_ARTIFACT} to Nordix Artifactory"
48   curl -s -S \
49       -H "X-JFrog-Art-Api:${NORDIX_ARM_TOKEN}" \
50       -H "X-Checksum-MD5:${ARTIFACT_MD5SUM}" \
51       -H "X-Checksum-Sha1:${ARTIFACT_SHASUM}" \
52       -H "X-Checksum-Sha256:${ARTIFACT_SHA256SUM}" \
53       -T "${BUILD_ARTIFACT}" \
54       "${NORDIX_ARTIFACT_URL}/${REMOTE_ARTIFACT}"
55   echo "Info  : Artifact ${BUILD_ARTIFACT} is available on ${NORDIX_ARTIFACT_URL}/${REMOTE_ARTIFACT}"
56 done
57
58 echo "Done!"
59
60 # vim: set ts=2 sw=2 expandtab: