liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # |
| 4 | # ============LICENSE_START================================================ |
| 5 | # ONAP |
| 6 | # ========================================================================= |
| 7 | # Copyright (C) 2021-2022 Nordix Foundation. |
| 8 | # ========================================================================= |
| 9 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | # you may not use this file except in compliance with the License. |
| 11 | # You may obtain a copy of the License at |
| 12 | # |
| 13 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | # |
| 15 | # Unless required by applicable law or agreed to in writing, software |
| 16 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | # See the License for the specific language governing permissions and |
| 19 | # limitations under the License. |
| 20 | # ============LICENSE_END================================================== |
| 21 | # |
| 22 | |
| 23 | set -e |
| 24 | |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 25 | SCRIPT_NAME=$(basename "$0") |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 26 | repo_location="./" |
| 27 | release_data_file="./pf_release_data.csv" |
| 28 | |
liamfallon | b76315a | 2022-01-12 13:24:54 +0000 | [diff] [blame] | 29 | # Use the bash internal OSTYPE variable to check for MacOS |
| 30 | if [[ "$OSTYPE" == "darwin"* ]] |
| 31 | then |
| 32 | SED="gsed" |
| 33 | else |
| 34 | SED="sed" |
| 35 | fi |
| 36 | |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 37 | usage() |
| 38 | { |
| 39 | echo "" |
| 40 | echo "$SCRIPT_NAME - updates the inter-repo references in Policy Framework POM files" |
| 41 | echo "" |
| 42 | echo " usage: $SCRIPT_NAME [-options]" |
| 43 | echo "" |
| 44 | echo " options" |
| 45 | echo " -h - this help message" |
| 46 | echo " -d data_file - the policy release data file to use, generated by the 'getReleaseData.sh' script," |
| 47 | echo " defaults to '$release_data_file'" |
| 48 | echo " -l location - the location of the policy framework repos on the file system," |
| 49 | echo " defaults to '$repo_location'" |
| 50 | echo " -r repo - the policy repo to update" |
| 51 | echo " -p - update policy/parent references" |
| 52 | echo " -c - update policy/common references" |
| 53 | echo " -m - update policy/model references" |
| 54 | echo " -o - update policy/drools-pdp references" |
liamfallon | 4d071bf | 2022-03-16 14:27:21 +0000 | [diff] [blame^] | 55 | echo " -x - update policy/apex-pdp references" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 56 | echo " -k - update docker base images in Dockerfiles" |
| 57 | echo " -s - update release references to snapshot references," |
| 58 | echo " if omitted, snapshot references are updated to release references" |
| 59 | echo "" |
| 60 | echo " examples:" |
| 61 | echo " $SCRIPT_NAME -pcm -r policy/pap" |
| 62 | echo " update the parent, common, and models references of policy/pap" |
| 63 | echo " to the current released version" |
| 64 | echo "" |
| 65 | echo " $SCRIPT_NAME -c -m -s -r policy/api" |
| 66 | echo " update the common and models references of policy/api" |
| 67 | echo " to the current snapshot version" |
| 68 | exit 255; |
| 69 | } |
| 70 | |
| 71 | update_parent=false |
| 72 | update_common=false |
| 73 | update_models=false |
| 74 | update_drools_pdp=false |
liamfallon | 4d071bf | 2022-03-16 14:27:21 +0000 | [diff] [blame^] | 75 | update_apex_pdp=false |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 76 | update_snapshot=false |
| 77 | update_docker=false |
| 78 | |
liamfallon | 4d071bf | 2022-03-16 14:27:21 +0000 | [diff] [blame^] | 79 | while getopts "hd:l:r:pcmoxks" opt |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 80 | do |
| 81 | case $opt in |
| 82 | h) |
| 83 | usage |
| 84 | ;; |
| 85 | d) |
| 86 | release_data_file=$OPTARG |
| 87 | ;; |
| 88 | l) |
| 89 | repo_location=$OPTARG |
| 90 | ;; |
| 91 | r) |
| 92 | specified_repo=$OPTARG |
| 93 | ;; |
| 94 | p) |
| 95 | update_parent=true |
| 96 | ;; |
| 97 | c) |
| 98 | update_common=true |
| 99 | ;; |
| 100 | m) |
| 101 | update_models=true |
| 102 | ;; |
| 103 | o) |
| 104 | update_drools_pdp=true |
| 105 | ;; |
liamfallon | 4d071bf | 2022-03-16 14:27:21 +0000 | [diff] [blame^] | 106 | x) |
| 107 | update_apex_pdp=true |
| 108 | ;; |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 109 | k) |
| 110 | update_docker=true |
| 111 | ;; |
| 112 | s) |
| 113 | update_snapshot=true |
| 114 | ;; |
| 115 | \?) |
| 116 | usage |
| 117 | exit 1 |
| 118 | ;; |
| 119 | esac |
| 120 | done |
| 121 | |
| 122 | if [ $OPTIND -eq 1 ] |
| 123 | then |
| 124 | echo "no arguments were specified" |
| 125 | usage |
| 126 | fi |
| 127 | |
| 128 | if [[ -z "$repo_location" ]] |
| 129 | then |
| 130 | echo "policy repo location not specified on -l flag" |
| 131 | exit 1 |
| 132 | fi |
| 133 | |
| 134 | if ! [ -d "$repo_location" ] |
| 135 | then |
| 136 | echo "policy repo location '$repo_location' not found" |
| 137 | exit 1 |
| 138 | fi |
| 139 | |
| 140 | if [[ -z "$release_data_file" ]] |
| 141 | then |
| 142 | echo "policy release data file not specified on -d flag" |
| 143 | exit 1 |
| 144 | fi |
| 145 | |
| 146 | if ! [ -f "$release_data_file" ] |
| 147 | then |
| 148 | echo "policy release data file '$release_data_file' not found" |
| 149 | exit 1 |
| 150 | fi |
| 151 | |
| 152 | if [ -z "$specified_repo" ] |
| 153 | then |
| 154 | echo "repo not specified on -r flag" |
| 155 | exit 1 |
| 156 | fi |
| 157 | |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 158 | # shellcheck disable=SC2034 |
| 159 | # shellcheck disable=SC2046 |
| 160 | read -r parent_repo \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 161 | parent_latest_released_tag \ |
| 162 | parent_latest_snapshot_tag \ |
| 163 | parent_changed_files \ |
| 164 | parent_docker_images \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 165 | <<< $(grep policy/parent "$release_data_file" | tr ',' ' ' ) |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 166 | |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 167 | # shellcheck disable=SC2034 |
| 168 | # shellcheck disable=SC2046 |
| 169 | read -r common_repo \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 170 | common_latest_released_tag \ |
| 171 | common_latest_snapshot_tag \ |
| 172 | common_changed_files \ |
| 173 | common_docker_images \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 174 | <<< $(grep policy/common "$release_data_file" | tr ',' ' ' ) |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 175 | |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 176 | # shellcheck disable=SC2034 |
| 177 | # shellcheck disable=SC2046 |
| 178 | read -r docker_repo \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 179 | docker_latest_released_tag \ |
| 180 | docker_latest_snapshot_tag \ |
| 181 | docker_changed_files \ |
| 182 | docker_docker_images \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 183 | <<< $(grep policy/docker "$release_data_file" | tr ',' ' ' ) |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 184 | |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 185 | # shellcheck disable=SC2034 |
| 186 | # shellcheck disable=SC2046 |
| 187 | read -r models_repo \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 188 | models_latest_released_tag \ |
| 189 | models_latest_snapshot_tag \ |
| 190 | models_changed_files \ |
| 191 | models_docker_images \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 192 | <<< $(grep policy/models "$release_data_file" | tr ',' ' ' ) |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 193 | |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 194 | # shellcheck disable=SC2034 |
| 195 | # shellcheck disable=SC2046 |
| 196 | read -r drools_pdp_repo \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 197 | drools_pdp_latest_released_tag \ |
| 198 | drools_pdp_latest_snapshot_tag \ |
| 199 | drools_pdp_changed_files \ |
| 200 | drools_pdp_docker_images \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 201 | <<< $(grep policy/drools-pdp "$release_data_file" | tr ',' ' ' ) |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 202 | |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 203 | # shellcheck disable=SC2034 |
| 204 | # shellcheck disable=SC2046 |
liamfallon | 4d071bf | 2022-03-16 14:27:21 +0000 | [diff] [blame^] | 205 | read -r apex_pdp_repo \ |
| 206 | apex_pdp_latest_released_tag \ |
| 207 | apex_pdp_latest_snapshot_tag \ |
| 208 | apex_pdp_changed_files \ |
| 209 | apex_pdp_docker_images \ |
| 210 | <<< $(grep policy/apex-pdp "$release_data_file" | tr ',' ' ' ) |
| 211 | |
| 212 | # shellcheck disable=SC2034 |
| 213 | # shellcheck disable=SC2046 |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 214 | read -r target_repo \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 215 | target_latest_released_tag \ |
| 216 | target_latest_snapshot_tag \ |
| 217 | target_changed_files \ |
| 218 | target_docker_images \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 219 | <<< $(grep "$specified_repo" "$release_data_file" | tr ',' ' ' ) |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 220 | |
| 221 | if [ -z "$target_repo" ] |
| 222 | then |
| 223 | echo "specified repo '$specified_repo' not found in policy release data file '$release_data_file'" |
| 224 | exit 1 |
| 225 | fi |
| 226 | |
| 227 | if [ ! "$specified_repo" = "$target_repo" ] |
| 228 | then |
| 229 | echo "specified repo '$specified_repo' does not match target repo '$target_repo'" |
| 230 | exit 1 |
| 231 | fi |
| 232 | |
| 233 | if [ "$update_parent" = true ] |
| 234 | then |
| 235 | if [ "$specified_repo" = "policy/parent" ] |
| 236 | then |
| 237 | if [ "$update_snapshot" = true ] |
| 238 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 239 | major_version=$(echo "$parent_latest_released_tag" | $SED -E 's/^([0-9]*)\.[0-9]*\.[0-9]*$/\1/') |
| 240 | minor_version=$(echo "$parent_latest_released_tag" | $SED -E 's/^[0-9]*\.([0-9]*)\.[0-9]*$/\1/') |
| 241 | patch_version=$(echo "$parent_latest_released_tag" | $SED -E 's/^[0-9]*\.[0-9]*\.([0-9]*)$/\1/') |
| 242 | new_patch_version=$(("$patch_version"+1)) |
| 243 | |
| 244 | new_snapshot_tag="$major_version"."$minor_version"."$new_patch_version"-SNAPSHOT |
| 245 | |
| 246 | echo updating policy parent reference to "$new_snapshot_tag" on "$repo_location/$target_repo" . . . |
liamfallon | b76315a | 2022-01-12 13:24:54 +0000 | [diff] [blame] | 247 | $SED -i \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 248 | "s/<version.parent.resources>.*<\/version.parent.resources>/<version.parent.resources>$new_snapshot_tag<\/version.parent.resources>/" \ |
| 249 | "$repo_location/policy/parent/integration/pom.xml" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 250 | result_code=$? |
| 251 | else |
| 252 | next_release_version=${parent_latest_snapshot_tag%-*} |
| 253 | |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 254 | echo "updating policy parent reference to $next_release_version on $repo_location/$target_repo . . ." |
liamfallon | b76315a | 2022-01-12 13:24:54 +0000 | [diff] [blame] | 255 | $SED -i \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 256 | "s/<version.parent.resources>.*<\/version.parent.resources>/<version.parent.resources>$next_release_version<\/version.parent.resources>/" \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 257 | "$repo_location/policy/parent/integration/pom.xml" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 258 | result_code=$? |
| 259 | fi |
| 260 | else |
| 261 | if [ "$update_snapshot" = true ] |
| 262 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 263 | echo "updating policy parent reference to $parent_latest_snapshot_tag on $repo_location/$target_repo . . ." |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 264 | updateParentRef.sh \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 265 | -f "$repo_location/$target_repo/pom.xml" \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 266 | -g org.onap.policy.parent \ |
| 267 | -a integration \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 268 | -v "$parent_latest_snapshot_tag" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 269 | result_code=$? |
| 270 | else |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 271 | echo "updating policy parent reference to $parent_latest_released_tag on $repo_location/$target_repo . . ." |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 272 | updateParentRef.sh \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 273 | -f "$repo_location/$target_repo/pom.xml" \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 274 | -g org.onap.policy.parent \ |
| 275 | -a integration \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 276 | -v "$parent_latest_released_tag" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 277 | result_code=$? |
| 278 | fi |
| 279 | fi |
| 280 | if [[ "$result_code" -eq 0 ]] |
| 281 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 282 | echo "policy parent reference updated on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 283 | else |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 284 | echo "policy parent reference update failed on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 285 | exit 1 |
| 286 | fi |
| 287 | fi |
| 288 | |
| 289 | if [ "$update_common" = true ] |
| 290 | then |
| 291 | if [ "$update_snapshot" = true ] |
| 292 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 293 | echo "updating policy common reference to $common_latest_snapshot_tag on $repo_location/$target_repo . . ." |
liamfallon | b76315a | 2022-01-12 13:24:54 +0000 | [diff] [blame] | 294 | $SED -i \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 295 | -e "s/<policy.common.version>.*<\/policy.common.version>/<policy.common.version>$common_latest_snapshot_tag<\/policy.common.version>/" \ |
| 296 | -e "s/<version.policy.common>.*<\/version.policy.common>/<version.policy.common>$common_latest_snapshot_tag<\/version.policy.common>/" \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 297 | "$repo_location/$target_repo/pom.xml" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 298 | result_code=$? |
| 299 | else |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 300 | echo "updating policy common reference to $common_latest_released_tag on $repo_location/$target_repo . . ." |
liamfallon | b76315a | 2022-01-12 13:24:54 +0000 | [diff] [blame] | 301 | $SED -i \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 302 | -e "s/<policy.common.version>.*<\/policy.common.version>/<policy.common.version>$common_latest_released_tag<\/policy.common.version>/" \ |
| 303 | -e "s/<version.policy.common>.*<\/version.policy.common>/<version.policy.common>$common_latest_released_tag<\/version.policy.common>/" \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 304 | "$repo_location/$target_repo/pom.xml" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 305 | result_code=$? |
| 306 | fi |
| 307 | if [[ "$result_code" -eq 0 ]] |
| 308 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 309 | echo "policy common reference updated on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 310 | else |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 311 | echo "policy common reference update failed on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 312 | exit 1 |
| 313 | fi |
| 314 | fi |
| 315 | |
| 316 | if [ "$update_models" = true ] |
| 317 | then |
| 318 | if [ "$update_snapshot" = true ] |
| 319 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 320 | echo "updating policy models reference to $models_latest_snapshot_tag on $repo_location/$target_repo . . ." |
liamfallon | b76315a | 2022-01-12 13:24:54 +0000 | [diff] [blame] | 321 | $SED -i \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 322 | -e "s/<policy.models.version>.*<\/policy.models.version>/<policy.models.version>$models_latest_snapshot_tag<\/policy.models.version>/" \ |
| 323 | -e "s/<version.policy.models>.*<\/version.policy.models>/<version.policy.models>$models_latest_snapshot_tag<\/version.policy.models>/" \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 324 | "$repo_location/$target_repo/pom.xml" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 325 | result_code=$? |
| 326 | else |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 327 | echo "updating policy models reference to $models_latest_released_tag on $repo_location/$target_repo . . ." |
liamfallon | b76315a | 2022-01-12 13:24:54 +0000 | [diff] [blame] | 328 | $SED -i \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 329 | -e "s/<policy.models.version>.*<\/policy.models.version>/<policy.models.version>$models_latest_released_tag<\/policy.models.version>/" \ |
| 330 | -e "s/<version.policy.models>.*<\/version.policy.models>/<version.policy.models>$models_latest_released_tag<\/version.policy.models>/" \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 331 | "$repo_location/$target_repo/pom.xml" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 332 | result_code=$? |
| 333 | fi |
| 334 | if [[ "$result_code" -eq 0 ]] |
| 335 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 336 | echo "policy models reference updated on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 337 | else |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 338 | echo "policy models reference update failed on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 339 | exit 1 |
| 340 | fi |
| 341 | fi |
| 342 | |
| 343 | if [ "$update_drools_pdp" = true ] |
| 344 | then |
| 345 | if [ "$update_snapshot" = true ] |
| 346 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 347 | echo "updating policy drools-pdp reference to $drools_pdp_latest_snapshot_tag on $repo_location/$target_repo . . ." |
liamfallon | b76315a | 2022-01-12 13:24:54 +0000 | [diff] [blame] | 348 | $SED -i \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 349 | -e "s/<policy.drools-pdp.version>.*<\/policy.drools-pdp.version>/<policy.drools-pdp.version>$drools_pdp_latest_snapshot_tag<\/policy.drools-pdp.version>/" \ |
| 350 | -e "s/<version.policy.drools-pdp>.*<\/version.policy.drools-pdp>/<version.policy.drools-pdp>$drools_pdp_latest_snapshot_tag<\/version.policy.drools-pdp>/" \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 351 | "$repo_location/$target_repo/pom.xml" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 352 | result_code=$? |
| 353 | else |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 354 | echo "updating policy drools-pdp reference to $drools_pdp_latest_released_tag on $repo_location/$target_repo . . ." |
liamfallon | b76315a | 2022-01-12 13:24:54 +0000 | [diff] [blame] | 355 | $SED -i \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 356 | -e "s/<policy.drools-pdp.version>.*<\/policy.drools-pdp.version>/<policy.drools-pdp.version>$drools_pdp_latest_released_tag<\/policy.drools-pdp.version>/" \ |
| 357 | -e "s/<version.policy.drools-pdp>.*<\/version.policy.drools-pdp>/<version.policy.drools-pdp>$drools_pdp_latest_released_tag<\/version.policy.drools-pdp>/" \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 358 | "$repo_location/$target_repo/pom.xml" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 359 | result_code=$? |
| 360 | fi |
| 361 | if [[ "$result_code" -eq 0 ]] |
| 362 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 363 | echo "policy drools-pdp reference updated on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 364 | else |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 365 | echo "policy drools-pdp reference update failed on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 366 | exit 1 |
| 367 | fi |
| 368 | fi |
| 369 | |
liamfallon | 4d071bf | 2022-03-16 14:27:21 +0000 | [diff] [blame^] | 370 | if [ "$update_apex_pdp" = true ] |
| 371 | then |
| 372 | if [ "$update_snapshot" = true ] |
| 373 | then |
| 374 | echo "updating policy apex-pdp reference to $apex_pdp_latest_snapshot_tag on $repo_location/$target_repo . . ." |
| 375 | $SED -i \ |
| 376 | -e "s/<policy.apex-pdp.version>.*<\/policy.apex-pdp.version>/<policy.apex-pdp.version>$apex_pdp_latest_snapshot_tag<\/policy.apex-pdp.version>/" \ |
| 377 | -e "s/<version.policy.apex-pdp>.*<\/version.policy.apex-pdp>/<version.policy.apex-pdp>$apex_pdp_latest_snapshot_tag<\/version.policy.apex-pdp>/" \ |
| 378 | "$repo_location/$target_repo/pom.xml" |
| 379 | result_code=$? |
| 380 | else |
| 381 | echo "updating policy apex-pdp reference to $apex_pdp_latest_released_tag on $repo_location/$target_repo . . ." |
| 382 | $SED -i \ |
| 383 | -e "s/<policy.apex-pdp.version>.*<\/policy.apex-pdp.version>/<policy.apex-pdp.version>$apex_pdp_latest_released_tag<\/policy.apex-pdp.version>/" \ |
| 384 | -e "s/<version.policy.apex-pdp>.*<\/version.policy.apex-pdp>/<version.policy.apex-pdp>$apex_pdp_latest_released_tag<\/version.policy.apex-pdp>/" \ |
| 385 | "$repo_location/$target_repo/pom.xml" |
| 386 | result_code=$? |
| 387 | fi |
| 388 | if [[ "$result_code" -eq 0 ]] |
| 389 | then |
| 390 | echo "policy apex-pdp reference updated on $repo_location/$target_repo" |
| 391 | else |
| 392 | echo "policy apex-pdp reference update failed on $repo_location/$target_repo" |
| 393 | exit 1 |
| 394 | fi |
| 395 | fi |
| 396 | |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 397 | if [ "$update_docker" = true ] && [ "$target_docker_images" != "" ] |
| 398 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 399 | echo "updating docker base images to version $docker_latest_released_tag on repo $repo_location/$target_repo . . ." |
| 400 | find "$repo_location/$target_repo" \ |
liamfallon | 4d071bf | 2022-03-16 14:27:21 +0000 | [diff] [blame^] | 401 | -name '*Docker*' |
| 402 | find "$repo_location/$target_repo" \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 403 | -name '*Docker*' \ |
liamfallon | 4d071bf | 2022-03-16 14:27:21 +0000 | [diff] [blame^] | 404 | -exec $SED -r -i "s/^(FROM onap\/policy-j[d|r][k|e]-alpine:)[0-9]*.[0-9]*.[0-9]*$/\1$docker_latest_released_tag/" {} \; |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 405 | result_code=$? |
| 406 | if [[ "$result_code" -eq 0 ]] |
| 407 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 408 | echo "docker base images updated on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 409 | else |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 410 | echo "docker base images update failed on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 411 | exit 1 |
| 412 | fi |
| 413 | fi |