rameshiyer27 | b15eda6 | 2024-02-14 10:13:16 +0000 | [diff] [blame] | 1 | #! /bin/bash |
| 2 | |
| 3 | # ============LICENSE_START==================================================== |
| 4 | # Copyright (C) 2024 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 | |
| 22 | function getDockerVersion |
| 23 | { |
| 24 | REPO=${1} |
| 25 | GERRIT_BRANCH=${2} |
| 26 | DEFAULT_DOCKER_IMAGE_NAME=${3:-} |
| 27 | DEFAULT_DOCKER_IMAGE_VERSION=${4:-} |
| 28 | |
| 29 | REPO_RELEASE_DATA=$( |
| 30 | curl -qL --silent \ |
| 31 | "https://github.com/onap/policy-parent/raw/${GERRIT_BRANCH}/integration/src/main/resources/release/pf_release_data.csv" | |
| 32 | grep "^policy/$REPO" |
| 33 | ) |
| 34 | |
| 35 | # shellcheck disable=SC2034 |
| 36 | read -r repo \ |
| 37 | latest_released_tag \ |
| 38 | latest_snapshot_tag \ |
| 39 | changed_files \ |
| 40 | docker_images \ |
| 41 | <<< "$(echo "$REPO_RELEASE_DATA" | tr ',' ' ' )" |
| 42 | |
| 43 | if [[ -z "$docker_images" ]] |
| 44 | then |
| 45 | if [[ -z "$DEFAULT_DOCKER_IMAGE_NAME" ]] |
| 46 | then |
| 47 | echo "repo $REPO does not produce a docker image, execution terminated" |
| 48 | exit 1 |
| 49 | else |
| 50 | docker_images="$DEFAULT_DOCKER_IMAGE_NAME" |
| 51 | fi |
| 52 | fi |
| 53 | |
| 54 | # docker_image_version=$(echo "$latest_snapshot_tag" | awk -F \. '{print $1"."$2"-SNAPSHOT-latest"}') |
| 55 | docker_image_version=$latest_snapshot_tag |
| 56 | docker_image_name=$(echo "$docker_images" | sed -e "s/^.*://" -e "s/^.//" -e "s/.$//") |
| 57 | |
| 58 | if \ |
| 59 | curl -qL --silent \ |
| 60 | "https://nexus3.onap.org/service/rest/repository/browse/docker.snapshot/v2/onap/$docker_image_name/tags/" | |
| 61 | grep -q "$docker_image_version" |
| 62 | then |
| 63 | echo "using \"$docker_image_name:$docker_image_version\" docker image for repo \"$repo\"" |
| 64 | return |
| 65 | fi |
| 66 | |
| 67 | docker_image_version="$latest_released_tag" |
| 68 | if \ |
| 69 | curl -qL --silent \ |
| 70 | "https://nexus3.onap.org/service/rest/repository/browse/docker.release/v2/onap/$docker_image_name/tags/" | |
| 71 | grep -q "$docker_image_version" |
| 72 | then |
| 73 | echo "using \"$docker_image_name:$docker_image_version\" docker image for repo \"$repo\"" |
| 74 | return |
| 75 | fi |
| 76 | |
| 77 | docker_image_version="$DEFAULT_DOCKER_IMAGE_VERSION" |
| 78 | if \ |
| 79 | curl -qL --silent \ |
| 80 | "https://nexus3.onap.org/service/rest/repository/browse/docker.release/v2/onap/$docker_image_name/tags/" | |
| 81 | grep -q "$docker_image_version" |
| 82 | then |
| 83 | echo "using \"$docker_image_name:$docker_image_version\" docker image for repo \"$repo\"" |
| 84 | return |
| 85 | else |
| 86 | echo "docker image \"$docker_image_name:$docker_image_version\" not found for repo \"$repo\"" |
| 87 | exit 1 |
| 88 | fi |
| 89 | } |
| 90 | |
| 91 | |
| 92 | if [ -z "${WORKSPACE}" ]; then |
| 93 | WORKSPACE=$(git rev-parse --show-toplevel) |
| 94 | export WORKSPACE |
| 95 | fi |
| 96 | |
| 97 | if [ $# -eq 0 ]; then |
| 98 | echo "No release versions provided. Fetching the default version for ACM and participants" |
| 99 | echo "Usage: $0 <acm_release> <participant_release> ..." |
| 100 | ACM_RELEASE=$(awk -F= '$1 == "defaultbranch" { print $2 }' \ |
| 101 | "${WORKSPACE}"/.gitreview) |
| 102 | PPNT_RELEASE=$ACM_RELEASE |
| 103 | fi |
| 104 | if [ $1 ]; then |
| 105 | ACM_RELEASE=$1 |
| 106 | fi |
| 107 | |
| 108 | if [ $2 ]; then |
| 109 | PPNT_RELEASE=$2 |
| 110 | fi |
| 111 | |
| 112 | export POLICY_MARIADB_VER=10.10.2 |
| 113 | echo POLICY_MARIADB_VER=${POLICY_MARIADB_VER} |
| 114 | |
| 115 | export POLICY_POSTGRES_VER=11.1 |
| 116 | echo POLICY_POSTGRES_VER=${POLICY_POSTGRES_VER} |
| 117 | |
| 118 | getDockerVersion models $ACM_RELEASE "'policy-models-simulator'" 3.0.1 |
| 119 | export POLICY_MODELS_VERSION="$docker_image_version" |
| 120 | |
| 121 | getDockerVersion docker $ACM_RELEASE |
| 122 | export POLICY_DOCKER_VERSION="$docker_image_version" |
| 123 | |
| 124 | getDockerVersion api $ACM_RELEASE |
| 125 | export POLICY_API_VERSION="$docker_image_version" |
| 126 | |
| 127 | getDockerVersion pap $ACM_RELEASE |
| 128 | export POLICY_PAP_VERSION="$docker_image_version" |
| 129 | |
| 130 | getDockerVersion apex-pdp $ACM_RELEASE |
| 131 | export POLICY_APEX_PDP_VERSION="$docker_image_version" |
| 132 | |
| 133 | getDockerVersion clamp $ACM_RELEASE |
| 134 | export POLICY_CLAMP_VERSION="$docker_image_version" |
| 135 | |
| 136 | getDockerVersion clamp $PPNT_RELEASE |
| 137 | export POLICY_CLAMP_PPNT_VERSION="$docker_image_version" |
| 138 | |
| 139 | getDockerVersion drools-pdp $ACM_RELEASE |
| 140 | export POLICY_DROOLS_PDP_VERSION="$docker_image_version" |
| 141 | |
| 142 | getDockerVersion xacml-pdp $ACM_RELEASE |
| 143 | export POLICY_XACML_PDP_VERSION="$docker_image_version" |
| 144 | |
| 145 | getDockerVersion distribution $ACM_RELEASE |
| 146 | export POLICY_DISTRIBUTION_VERSION="$docker_image_version" |
| 147 | |
| 148 | getDockerVersion drools-applications $ACM_RELEASE |
| 149 | export POLICY_DROOLS_APPS_VERSION="$docker_image_version" |