blob: 0e8f251e7ed7ebc0b360c879addf0228e4a52231 [file] [log] [blame]
liamfallone84250c2022-06-17 11:11:55 +01001#! /bin/bash
2
Taka Cho6d188af2021-01-11 16:48:33 -05003# ============LICENSE_START====================================================
4# Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
rameshiyer27b15eda62024-02-14 10:13:16 +00005# Modification Copyright 2021-2024 Nordix Foundation.
a.sreekumard00369a2021-10-19 12:38:04 +01006# Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
Taka Cho6d188af2021-01-11 16:48:33 -05007# =============================================================================
8# Licensed under the Apache License, Version 2.0 (the "License");
9# you may not use this file except in compliance with the License.
10# You may obtain a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing, software
15# distributed under the License is distributed on an "AS IS" BASIS,
16# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17# See the License for the specific language governing permissions and
18# limitations under the License.
19#
20# SPDX-License-Identifier: Apache-2.0
21# ============LICENSE_END======================================================
22
adheli.tavares1f339f82023-02-17 15:14:07 +000023if [ -z "${WORKSPACE}" ]; then
24 WORKSPACE=$(git rev-parse --show-toplevel)
25 export WORKSPACE
liamfallone84250c2022-06-17 11:11:55 +010026fi
Taka Cho6d188af2021-01-11 16:48:33 -050027
adheli.tavaresd802fd92024-08-15 12:39:19 +010028LOCAL_IMAGES=false
29
adheli.tavaresdaecbb92024-07-19 13:50:04 +010030#default values
liamfallon0a85ebf2022-12-18 02:24:07 +000031export POLICY_MARIADB_VER=10.10.2
Taka Cho6d188af2021-01-11 16:48:33 -050032echo POLICY_MARIADB_VER=${POLICY_MARIADB_VER}
33
adheli.tavaresd802fd92024-08-15 12:39:19 +010034export POLICY_POSTGRES_VER=16.4
waynedunican74501192022-03-16 08:10:54 +000035echo POLICY_POSTGRES_VER=${POLICY_POSTGRES_VER}
36
adheli.tavaresdaecbb92024-07-19 13:50:04 +010037if [ -n "$LOCAL_IMAGES" ] && [ "$LOCAL_IMAGES" = "true" ]; then
38 echo "Running with local images."
39 export POLICY_DOCKER_VERSION="latest"
40 export POLICY_MODELS_VERSION="latest"
41 export POLICY_API_VERSION="latest"
42 export POLICY_PAP_VERSION="latest"
43 export POLICY_APEX_PDP_VERSION="latest"
44 export POLICY_DROOLS_PDP_VERSION="latest"
45 export POLICY_XACML_PDP_VERSION="latest"
46 export POLICY_DISTRIBUTION_VERSION="latest"
47 export POLICY_CLAMP_VERSION="latest"
48 export POLICY_CLAMP_PPNT_VERSION=$POLICY_CLAMP_VERSION
49 export POLICY_DROOLS_APPS_VERSION="latest"
adheli.tavaresd802fd92024-08-15 12:39:19 +010050 export CONTAINER_LOCATION=""
liamfallonf66c6832022-06-28 15:55:29 +010051
adheli.tavaresdaecbb92024-07-19 13:50:04 +010052else
adheli.tavaresd802fd92024-08-15 12:39:19 +010053 export CONTAINER_LOCATION="nexus3.onap.org:10001/"
adheli.tavaresdaecbb92024-07-19 13:50:04 +010054 GERRIT_BRANCH=$(awk -F= '$1 == "defaultbranch" { print $2 }' \
55 "${WORKSPACE}"/.gitreview)
liamfallonf66c6832022-06-28 15:55:29 +010056
adheli.tavaresdaecbb92024-07-19 13:50:04 +010057 echo GERRIT_BRANCH="${GERRIT_BRANCH}"
liamfallonf66c6832022-06-28 15:55:29 +010058
adheli.tavaresdaecbb92024-07-19 13:50:04 +010059 function getDockerVersion
60 {
61 REPO=${1}
62 DEFAULT_DOCKER_IMAGE_NAME=${2:-}
63 DEFAULT_DOCKER_IMAGE_VERSION=${3:-}
64
65 REPO_RELEASE_DATA=$(
66 curl -qL --silent \
67 "https://github.com/onap/policy-parent/raw/$GERRIT_BRANCH/integration/src/main/resources/release/pf_release_data.csv" |
68 grep "^policy/$REPO"
69 )
70
71 # shellcheck disable=SC2034
72 read -r repo \
73 latest_released_tag \
74 latest_snapshot_tag \
75 changed_files \
76 docker_images \
77 <<< "$(echo "$REPO_RELEASE_DATA" | tr ',' ' ' )"
78
79 if [[ -z "$docker_images" ]]
liamfallonf66c6832022-06-28 15:55:29 +010080 then
adheli.tavaresdaecbb92024-07-19 13:50:04 +010081 if [[ -z "$DEFAULT_DOCKER_IMAGE_NAME" ]]
82 then
83 echo "repo $REPO does not produce a docker image, execution terminated"
84 exit 1
85 else
86 docker_images="$DEFAULT_DOCKER_IMAGE_NAME"
87 fi
liamfallonf66c6832022-06-28 15:55:29 +010088 fi
liamfallonf66c6832022-06-28 15:55:29 +010089
adheli.tavaresdaecbb92024-07-19 13:50:04 +010090 # docker_image_version=$(echo "$latest_snapshot_tag" | awk -F \. '{print $1"."$2"-SNAPSHOT-latest"}')
91 docker_image_version=$latest_snapshot_tag
92 docker_image_name=$(echo "$docker_images" | sed -e "s/^.*://" -e "s/^.//" -e "s/.$//")
liamfallonf66c6832022-06-28 15:55:29 +010093
adheli.tavaresdaecbb92024-07-19 13:50:04 +010094 if \
95 curl -qL --silent \
96 "https://nexus3.onap.org/service/rest/repository/browse/docker.snapshot/v2/onap/$docker_image_name/tags/" |
97 grep -q "$docker_image_version"
98 then
99 echo "using \"$docker_image_name:$docker_image_version\" docker image for repo \"$repo\""
100 return
101 fi
liamfallonf66c6832022-06-28 15:55:29 +0100102
adheli.tavaresdaecbb92024-07-19 13:50:04 +0100103 docker_image_version="$latest_released_tag"
104 if \
105 curl -qL --silent \
106 "https://nexus3.onap.org/service/rest/repository/browse/docker.release/v2/onap/$docker_image_name/tags/" |
107 grep -q "$docker_image_version"
108 then
109 echo "using \"$docker_image_name:$docker_image_version\" docker image for repo \"$repo\""
110 return
111 fi
liamfallonf66c6832022-06-28 15:55:29 +0100112
adheli.tavaresdaecbb92024-07-19 13:50:04 +0100113 docker_image_version="$DEFAULT_DOCKER_IMAGE_VERSION"
114 if \
115 curl -qL --silent \
116 "https://nexus3.onap.org/service/rest/repository/browse/docker.release/v2/onap/$docker_image_name/tags/" |
117 grep -q "$docker_image_version"
118 then
119 echo "using \"$docker_image_name:$docker_image_version\" docker image for repo \"$repo\""
120 return
121 else
122 echo "docker image \"$docker_image_name:$docker_image_version\" not found for repo \"$repo\""
123 exit 1
124 fi
125 }
Jim Hahncfc44f02021-04-08 15:28:15 -0400126
adheli.tavaresdaecbb92024-07-19 13:50:04 +0100127 getDockerVersion docker
128 export POLICY_DOCKER_VERSION="$docker_image_version"
Taka Cho6d188af2021-01-11 16:48:33 -0500129
adheli.tavaresd802fd92024-08-15 12:39:19 +0100130 getDockerVersion models
adheli.tavaresdaecbb92024-07-19 13:50:04 +0100131 export POLICY_MODELS_VERSION="$docker_image_version"
Taka Cho6d188af2021-01-11 16:48:33 -0500132
adheli.tavaresdaecbb92024-07-19 13:50:04 +0100133 getDockerVersion api
134 export POLICY_API_VERSION="$docker_image_version"
Taka Cho6d188af2021-01-11 16:48:33 -0500135
adheli.tavaresdaecbb92024-07-19 13:50:04 +0100136 getDockerVersion pap
137 export POLICY_PAP_VERSION="$docker_image_version"
Taka Cho6d188af2021-01-11 16:48:33 -0500138
adheli.tavaresdaecbb92024-07-19 13:50:04 +0100139 getDockerVersion apex-pdp
140 export POLICY_APEX_PDP_VERSION="$docker_image_version"
Taka Cho6d188af2021-01-11 16:48:33 -0500141
adheli.tavaresdaecbb92024-07-19 13:50:04 +0100142 getDockerVersion drools-pdp
143 export POLICY_DROOLS_PDP_VERSION="$docker_image_version"
Taka Cho6d188af2021-01-11 16:48:33 -0500144
adheli.tavaresdaecbb92024-07-19 13:50:04 +0100145 getDockerVersion xacml-pdp
146 export POLICY_XACML_PDP_VERSION="$docker_image_version"
Taka Cho6d188af2021-01-11 16:48:33 -0500147
adheli.tavaresdaecbb92024-07-19 13:50:04 +0100148 getDockerVersion distribution
149 export POLICY_DISTRIBUTION_VERSION="$docker_image_version"
Sirisha_Manchikanti4d0a1d72021-06-08 09:28:21 +0100150
adheli.tavaresdaecbb92024-07-19 13:50:04 +0100151 getDockerVersion clamp
152 export POLICY_CLAMP_VERSION="$docker_image_version"
153 export POLICY_CLAMP_PPNT_VERSION=$POLICY_CLAMP_VERSION
ktimoney88a991b2021-08-09 17:23:35 +0100154
adheli.tavaresdaecbb92024-07-19 13:50:04 +0100155 getDockerVersion drools-applications
156 export POLICY_DROOLS_APPS_VERSION="$docker_image_version"
157fi